I have a situation similar to that described in Fluent NHibernate Mapping not on PK Field
However, the relationship between my tables is described by multiple non-primar
using hbm.xml and FluentNHibernate it is possible with a trick
class PersonMap : ClassMap
{
public PersonMap()
{
Map(_ => JobTypeAndCode)
.Columns.Add("Person_JobType", "Person_Code")
.ReadOnly()
.LazyLoad() // optional: prevent loading the Columns twice
.Access.None();
HasMany(p => p.Orders)
.KeyColumns.Add("Person_JobType", "Person_Code")
.PropertyRef("JobTypeAndCode")
}
private object JobTypeAndCode { get; set; } // FakeProperty
}
Note: i never got this to work using NHibernate MappingByCode