Aleksej, This group is for the development OF NHibernate. Please send your question to the *nhusers* group, and/or post it in Stackoverflow using the nhibernate tag.
Diego On Wed, Jun 27, 2012 at 8:47 AM, Aleksej Milorava <[email protected]>wrote: > > > <http://stackoverflow.com/questions/11159954/nhibernate-mapping-by-code-map-collection#> > > Hi, > > I'm moving from xml mapping to a code based mapping. There is a problem > I'm experiencing with NHibernate Map collection. > > Below is the xml mapping which perfectly works: > > <class name="Company" where="IsDeleted=0" lazy="false"> > <id name="Id"> > <generator class="guid"></generator> > </id> > <map name="Contacts" lazy="true" cascade="all" > where="IsDeleted=0"> > <key column="CompanyId"></key> > <map-key column="Id" type="guid"/> > <one-to-many class="CompanyContact"/> > </map> > </class> > > The alternate code mapping I came up with is next: > > public CompanyMap() > { > Id(x => x.Id, mapper => mapper.Generator(Generators.Guid)); > Map(x => x.Contacts, > m => > { > m.Where(FILTER); > m.Cascade(Cascade.All); > m.Lazy(CollectionLazy.Lazy); > m.Key(c => c.Column("CompanyId")); > }, k => > { > k.Element(e => > { > e.Column("Id"); > }); > k.OneToMany(e => e.Class(typeof(CompanyContact))); > }); > } > > The above generates next hbml for map: > > <map name="Contacts" lazy="true" cascade="all" where="IsDeleted=0"> > <key column="CompanyId" /> > <map-key type="Guid" /> > <one-to-many class="CompanyContact" /> > </map> > > > My question is how would I set the column property of map-key? > > Thank you, > Aleksej >
