I am new to fluent NHibernate. Now I face one problem with mapping composite keys. Can anyone point out the URL or sample please?
There may be a need for entities with composite identifiers, entities that map to tables which have composite primary keys, composed of many columns. The columns that make up this primary key are usually foreign keys to another tables.
public class UserMap : ClassMap
{
public UserMap()
{
Table("User");
Id(x => x.Id).Column("ID");
CompositeId()
.KeyProperty(x => x.Id, "ID")
.KeyReference(x => x.User, "USER_ID");
Map(x => x.Name).Column("NAME");
References(x => x.Company).Column("COMPANY_ID").ForeignKey("ID");
}
}
For more reference : http://www.codeproject.com/Tips/419780/NHibernate-mappings-for-Composite-Keys-with-associ