I have to admit that I didn't read the whole thread.

When using reflection, a explicit implementation of a property has the
name "InterfaceNamespace.Interface.PropertyName". So you should try
this in the mapping file.

About the design: I also tried explicit interface implementations and
removed most of them afterwards. It's kind of awkward, it's not
inherited and hard to understand.

In my point of view it's always best to either declare the properties
to be the same, so you have to implement them only once, or use
different names.

On the other hand you are right that explicit interface implementation
is a .NET feature that needs to be used sometimes and should be
supported by NH.


On Mar 25, 5:37 pm, Joshua <[email protected]> wrote:
> Thanks James and TigerShark.
>
> I think what I'm hearing from you is that I should just map the two
> properties in my entity to appropriately (read differently) named
> properties and not implement the interfaces at all?  Correct?
>
> Being a newb with DDD and ORM's, do you think you could point me in
> the right direction with how to design a DTO solution.  Make whatever
> naive assumptions about my situation you need to.  I just need a
> starting point, please.
>
> Thanks.
>
> On Mar 25, 10:00 am, James Gregory <[email protected]> wrote:
>
> > I think we all know what you're trying to achieve, it's just not a very good
> > idea to do it in an entity. It may not even be possible to do that kind of
> > mapping with NHibernate. I don't know because it's never something that I
> > would consider doing. If it's some obtuse requirement of a service you have
> > no control over, then I'd personally create a DTO that interacts with it
> > that implements the appropriate behavior, and map between a properly
> > designed model and that DTO. Don't try to bring that mess down into the
> > model too.
>
> > On Wed, Mar 25, 2009 at 3:55 PM, Joshua <[email protected]> wrote:
>
> > > I think my design is so odd to you that I'm going to simplify
> > > further.  One major question I have is how to implement explicit
> > > interface implementations.  My entity must implement two interfaces
> > > with the same name in order to interact with the rest of the domain
> > > for which the design is not up to me.  I must persist all of the
> > > relevant data.  Here is my updated domain and skeletal mapping.
> > > Please recommend how you were persist the "Foo" properties using
> > > NHibernate, however seems best to you.
>
> > >    public interface IFoo1
> > >    {
> > >        string Foo
> > >        {
> > >            get;
> > >            set;
> > >        }
>
> > >    }
>
> > >    public interface IFoo2
> > >    {
> > >        string Foo
> > >        {
> > >            get;
> > >            set;
> > >        }
>
> > >    }
>
> > >    public class ConcreteFoo : IFoo1, IFoo2
> > >     {
> > >        public virtual int Id
> > >        {
> > >            get;
> > >            set;
> > >        }
>
> > >         string IFoo1.Foo
> > >        {
> > >            get;
> > >            set;
> > >        }
>
> > >        string IFoo2.Foo
> > >        {
> > >            get;
> > >            set;
> > >         }
> > >    }
>
> > > <?xml version="1.0" encoding="utf-8" ?>
> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> > > assembly="MappingTests" namespace="MappingTests">
> > >  <class name="ConcreteFoo">
> > >    <id name="Id">
> > >      <generator class="identity" />
> > >    </id>
> > >   </class>
> > > </hibernate-mapping>
>
> > > [TestFixture]
> > >    public class FooTests
> > >    {
> > >        [Test]
> > >        public void Test()
> > >        {
> > >            Configuration cfg = new Configuration();
> > >            cfg = cfg.Configure();
> > >            ISessionFactory factory = cfg.BuildSessionFactory();
> > >            using (ISession session = factory.OpenSession())
> > >            {
> > >                new SchemaExport(cfg).Execute(false, true, false,
> > > true, session.Connection, null);
>
> > >                ConcreteFoo foo = new ConcreteFoo();
> > >                 ((IFoo1)foo).Foo = "foo";
>
> > >                session.Save(foo);
> > >            }
> > >        }
> > >    }
>
> > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to