That sure did it. Thanks again. This is going to make my life SO much easier.
On Mar 26, 3:16 am, Stefan Steinegger <stefan....@bluewin.ch> wrote: > I really don't know, would have to try myself. Are there different > columns for the properties? You probably should try to define a column > name. > > On 26 Mrz., 05:19, Joshua <jno...@gmail.com> wrote: > > > Thanks Stefan. > > > I'm now able to implement one of the interface properties explicitly, > > but when I add the second I get: > > > TestCase 'MappingTests.FooTests.Test' > > failed: System.ArgumentOutOfRangeException : Index was out of range. > > Must be non-negative and less than the size of the collection. > > Parameter name: index > > at System.ThrowHelper.ThrowArgumentOutOfRangeException > > (ExceptionArgument argument, ExceptionResource resource) > > at System.ThrowHelper.ThrowArgumentOutOfRangeException() > > at System.Collections.Generic.List`1.get_Item(Int32 index) > > at System.Data.SQLite.SQLiteParameterCollection.GetParameter(Int32 > > index) > > at > > System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item > > (Int32 index) > > at NHibernate.Type.AbstractStringType.Set(IDbCommand cmd, Object > > value, Int32 index) > > at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object > > value, Int32 index) > > at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object > > value, Int32 index, Boolean[] settable, ISessionImplementor session) > > at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate > > (Object id, Object[] fields, Object rowId, Boolean[] includeProperty, > > Boolean[][] includeColumns, Int32 table, IDbCommand statement, > > ISessionImplementor session, Int32 index) > > at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate > > (Object id, Object[] fields, Boolean[] includeProperty, Boolean[][] > > includeColumns, Int32 j, IDbCommand st, ISessionImplementor session) > > at > > NHibernate.Persister.Entity.AbstractEntityPersister.GeneratedIdentifierBinder.BindValues > > (IDbCommand ps) > > at NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert > > (SqlCommandInfo insertSQL, ISessionImplementor session, IBinder > > binder) > > at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object > > [] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, > > ISessionImplementor session) > > at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object > > [] fields, Object obj, ISessionImplementor session) > > at NHibernate.Action.EntityIdentityInsertAction.Execute() > > at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) > > at > > NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate > > (Object entity, EntityKey key, IEntityPersister persister, Boolean > > useIdentityColumn, Object anything, IEventSource source, Boolean > > requiresImmediateIdAccess) > > at NHibernate.Event.Default.AbstractSaveEventListener.PerformSave > > (Object entity, Object id, IEntityPersister persister, Boolean > > useIdentityColumn, Object anything, IEventSource source, Boolean > > requiresImmediateIdAccess) > > at > > NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId > > (Object entity, String entityName, Object anything, IEventSource > > source, Boolean requiresImmediateIdAccess) > > at > > NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId > > (SaveOrUpdateEvent event) > > at > > NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId > > (SaveOrUpdateEvent event) > > at > > NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient > > (SaveOrUpdateEvent event) > > at > > NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate > > (SaveOrUpdateEvent event) > > at > > NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate > > (SaveOrUpdateEvent event) > > at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) > > at NHibernate.Impl.SessionImpl.Save(Object obj) > > > mapping: > > > <?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> > > <property name="MappingTests.IFoo1.Foo" /> > > <property name="MappingTests.IFoo2.Foo" /> > > </class> > > </hibernate-mapping> > > > Appropriate parts of the test: > > > ConcreteFoo foo = new ConcreteFoo(); > > ((IFoo1)foo).Foo = "foo1"; > > ((IFoo2)foo).Foo = "foo2"; > > > session.Save(foo); > > > Any ideas? I tried against SQL Server as well and got the same > > exception. This exception looks to me like NHibernate legitimately > > doesn't support explicit interface mapping with the same name. > > > On Mar 25, 3:27 pm, Stefan Steinegger <stefan....@bluewin.ch> wrote: > > > > 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 <jno...@gmail.com> 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 <jagregory....@gmail.com> 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 <jno...@gmail.com> 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); > > > > > > } > > > > > > } > > > > > > } > > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---