If you get (a recent) NHibernate via Nuget it should resolve to the correct Iesi dependency automatically.
/Oskar 2013/5/25 Oskar Berggren <oskar.bergg...@gmail.com> > You have download iesi.collections 4.0 which is for use with .Net 4 (where > ISet is builtin) and the future NHibernate 4.0. > > You should use the iesi.collections included with your copy of NHibernate. > > /Oskar > > > 2013/5/25 Riderman Sousa <riderma...@bindsolution.com> > >> Even after installing the package via nuget >> Iesi.Collections<http://nuget.org/packages/Iesi.Collections/>I can not set >> my collection as ISet >> <>; >> >> [image: Inline image 1] >> >> [image: Inline image 2] >> >> >> On Fri, May 24, 2013 at 6:07 PM, Riderman Sousa < >> riderma...@bindsolution.com> wrote: >> >>> I do not want to create a new dependency in my domain. Because if I have >>> to migrate ORM this can be a problem. >>> >>> Is there any way to accomplish this without creating a dependency? >>> >>> >>> On Fri, May 24, 2013 at 5:24 PM, Carl Bussema <carl.buss...@gmail.com>wrote: >>> >>>> If you're mapping as a set, you need to use >>>> Iesi.Collections.Generic.ISet<T> as the object type in your domain >>>> (implemented by HashedSet<T> normally). >>>> >>>> See >>>> http://stackoverflow.com/questions/1916350/list-vs-set-vs-bag-in-nhibernate >>>> >>>> >>>> On Fri, May 24, 2013 at 4:12 PM, Riderman Sousa < >>>> riderma...@bindsolution.com> wrote: >>>> >>>>> I have a domain class: >>>>> >>>>> public class Agencia : IEntity >>>>> { >>>>> public virtual int Id { get; set; } >>>>> >>>>> public virtual string Nome { get; set; } >>>>> >>>>> public virtual string Identificacao { get; set; } >>>>> >>>>> public virtual IList<Pessoa> Gerentes { get; protected set; } >>>>> >>>>> public Agencia() >>>>> { >>>>> Gerentes = new List<Pessoa>(); >>>>> } >>>>> >>>>> public virtual void AddGerente(Pessoa gerente) >>>>> { >>>>> Gerentes.Add(gerente); >>>>> } >>>>> public virtual void AddGerentes(params Pessoa[] gerentes) >>>>> { >>>>> Parallel.ForEach(gerentes, (pessoa) => Gerentes.Add(pessoa)); >>>>> } >>>>> } >>>>> public class Pessoa: IEntity >>>>> { >>>>> public virtual int Id { get; set; } >>>>> >>>>> public virtual string Nome { get; set; } >>>>> >>>>> } >>>>> >>>>> With this convention (defined as set AsSet) >>>>> >>>>> public class AgenciaConvention : IAutoMappingOverride<Agencia> >>>>> { >>>>> public void Override(AutoMapping<Agencia> mapping) >>>>> { >>>>> mapping.HasManyToMany(a => >>>>> a.Gerentes).Cascade.AllDeleteOrphan().AsSet().Not.Inverse(); >>>>> } >>>>> } >>>>> >>>>> When I run this test: >>>>> >>>>> >>>>> [TestMethod] >>>>> [Description("Uma agência tem vários gerêntes")]public void >>>>> AgenciaTemVariosGerentes() >>>>> { >>>>> // Arrange >>>>> var fix = new Fixture(); >>>>> var currentUser = GetLoggedUser(); >>>>> >>>>> // Create a List<Pessoa> >>>>> >>>>> var gerentes = fix.Build<Pessoa>() >>>>> .With(p => p.Nome) >>>>> .With(p => p.CPF) >>>>> .With(p => p.CreateBy, currentUser) >>>>> .OmitAutoProperties() >>>>> .CreateMany<Pessoa>(10).ToList(); >>>>> >>>>> // Action >>>>> >>>>> new PersistenceSpecification<Agencia>(Session) >>>>> .CheckProperty(p => p.Nome, fix.Create<string>().Truncate(80)) >>>>> .CheckProperty(p => p.Identificacao, >>>>> fix.Create<string>().Truncate(10)) >>>>> .CheckReference(p => p.Regional, >>>>> fix.Build<Regional>() >>>>> .With(p => p.Nome) >>>>> .OmitAutoProperties() >>>>> .Create() >>>>> , new IDEqualityComparer()) >>>>> .CheckList(p => p.Gerentes, gerentes, new >>>>> IDEqualityComparer()) >>>>> .CheckReference(p => p.CreateBy, currentUser, new >>>>> IDEqualityComparer()) >>>>> .VerifyTheMappings(); // Assert >>>>> } >>>>> >>>>> How can I test this list? >>>>> >>>>> The collection should be AsSet, it necessary that the Parent and >>>>> Children fields are PK, FK >>>>> >>>>> *Error:* >>>>> >>>>> Test Name: AgenciaTemVariosGerentes >>>>> Test FullName: >>>>> {OMMITED}.Integration.Test.AgenciaTest.AgenciaTemVariosGerentes >>>>> Test Source: {OMMITED}.Integration.Test\AgenciaTest.cs : line 22 >>>>> Test Outcome: Failed >>>>> Test Duration: 0:00:02,4093555 >>>>> >>>>> Result Message: >>>>> Test method >>>>> {OMMITED}.Integration.Test.AgenciaTest.AgenciaTemVariosGerentes threw >>>>> exception: >>>>> NHibernate.PropertyAccessException: Invalid Cast (check your mapping >>>>> for property type mismatches); setter of >>>>> CreditoImobiliarioBB.Model.Regional ---> System.InvalidCastException: >>>>> Unable to cast object of type >>>>> 'NHibernate.Collection.Generic.PersistentGenericSet`1[CreditoImobiliarioBB.Model.Pessoa]' >>>>> to type >>>>> 'System.Collections.Generic.IList`1[CreditoImobiliarioBB.Model.Pessoa]'. >>>>> Result StackTrace: >>>>> at (Object , Object[] , SetterCallback ) >>>>> at >>>>> NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues(Object >>>>> target, Object[] values) >>>>> at >>>>> NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object >>>>> entity, Object[] values) >>>>> --- End of inner exception stack trace --- >>>>> at >>>>> NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object >>>>> entity, Object[] values) >>>>> at >>>>> NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValues(Object >>>>> entity, >>>>> Object[] values) >>>>> at >>>>> NHibernate.Persister.Entity.AbstractEntityPersister.SetPropertyValues(Object >>>>> obj, Object[] values, EntityMode entityMode) >>>>> 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) >>>>> at >>>>> FluentNHibernate.Testing.PersistenceSpecification`1.TransactionalSave(Object >>>>> propertyValue) >>>>> at >>>>> FluentNHibernate.Testing.Values.ReferenceProperty`2.HasRegistered(PersistenceSpecification`1 >>>>> specification) >>>>> at >>>>> FluentNHibernate.Testing.PersistenceSpecification`1.RegisterCheckedProperty(Property`1 >>>>> property, IEqualityComparer equalityComparer) >>>>> at >>>>> FluentNHibernate.Testing.PersistenceSpecificationExtensions.CheckReference[T](PersistenceSpecification`1 >>>>> spec, Expression`1 expression, Object propertyValue, IEqualityComparer >>>>> propertyComparer) >>>>> at >>>>> CreditoImobiliarioBB.Repository.Integration.Test.AgenciaTest.AgenciaTemVariosGerentes() >>>>> in {OMMITED}.Integration.Test\AgenciaTest.cs:line 27 >>>>> >>>>> Thanks. >>>>> >>>>> Riderman de Sousa Barbosa <http://about.me/ridermansb> >>>>> >>>>> Web Developer | MCPD Certify >>>>> >>>>> Skype.: 4042-6002 | Cel.: (31) 8681-1986 >>>>> bindsolution.com >>>>> >>>>> Microsoft Parner Network >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Fluent NHibernate" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>>>> To post to this group, send email to >>>>> fluent-nhibernate@googlegroups.com. >>>>> Visit this group at >>>>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Fluent NHibernate" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to fluent-nhibernate+unsubscr...@googlegroups.com. >>>> To post to this group, send email to fluent-nhibernate@googlegroups.com >>>> . >>>> Visit this group at >>>> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Fluent NHibernate" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to fluent-nhibernate+unsubscr...@googlegroups.com. >> To post to this group, send email to fluent-nhibernate@googlegroups.com. >> Visit this group at >> http://groups.google.com/group/fluent-nhibernate?hl=en-US. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
<<image.png>>
<<image.png>>