I am upgrading to NHibernate 3.2. I was using Fluent NHibernate but I don't see a new build for NH 3.2. I am looking at using the included Conform mapper but it does not appear to allow for a composite id. I can't change the database so I have a constraint.
In Fluent NHibernate I had this (names changed for example only):
Schema("MY_SCHEMA");
Table("MY_TABLE");
CompositeId()
.KeyProperty(x => x.CompanyId, "COMPANY_ID")
.KeyProperty(x => x.OrderId, "ORDER_ID")
.KeyProperty(x => x.OrderDate, "ORDER_DATE")
.KeyProperty(x => x.ProgramId, "PROGRAM_ID");
How would I do this with Conform in NH 3.2?
Thanks, Paul
You can try with:
mapper.Class<YourEntity>(m=>{
m.Table("MY_TABLE");
m.Schema("MY_SCHEMA");
m.ComposedId(cid=>
{
cid.Property((e)=>e.CompanyId);
cid.Property((e)=>e.OrderId);
cid.Property((e)=>e.OrderDate);
//others...
});
});
And, I'm just guessing since I can't figura out your db, you would probably map the single portion of the key a many-to-one ( ie the old key-many-to-one you would write in hbm ), in order to do so, use cid.ManyToOne()
instead of cid.Property(..)
;