I have a database that accepts no null values and has a default for every field. Using fluent nHibernate, I am getting an error on an Insert if I have a component that has some, but not all properties filled out. I am just wondering how to get the DynamicInsert flag down to the component level. Perhaps it is late, but I'll just drop this off here and see where it goes.
mapping:
public ClientMap()
{
Table("Clients");
DynamicInsert();
DynamicUpdate();
CompositeId()
.KeyProperty(x => x.Accountnumber, "acct_no")
.KeyProperty(x => x.Transferaccount, "tr_acct_no");
Component(c => c.Address,
m =>{
m.Map(x => x.Streetaddress, "coaddress").Not.Nullable().Default("");
m.Map(x => x.City, "cocity").Not.Nullable().Default("");
m.Map(x => x.Postalcode, "costate").Not.Nullable().Default("");
m.Map(x => x.State, "cozip").Not.Nullable().Default(""); });
}
test:
Client nw = new Client{ Address = new Address{Streetaddress = "my address"},Accountnumber = "6543219",Transferaccount = "1"};
IRepository repo2 = new Repository(session);
repo2.Save(nw);
error:
could not insert: [BusinessObjects.Client#BusinessObjects.Client][SQL: INSERT INTO Clients (coaddress, cocity, cozip, costate, acct_no, tr_acct_no) VALUES (?, ?, ?, ?, ?, ?)]