开发者

What is the purpose Fluent NHiberate's KeyUpdate method?

I have a collection mapped as a query only property following Ayende's example. My mapping is:

HasMany<Employee>(Reveal.Member<Company>("_employees")).Access.None();

This worked fine, except when I load a Company the foreign key Employee.CompanyId is updated to null. This occurs even if I don't update Company and the generated SQL only includes the CompanyId in the update list even though I have not mapped Employee to update changed properties only.

I tried usin开发者_StackOverflow中文版g NoOp (they're synonyms I think) and declaring the employees collection as a public property instead of a private field. I was finally able to fix it by changing the mapping to:

HasMany(Reveal.Member("_employees")).Access.None().Not.KeyUpdate();

What is the purpose of KeyUpdate and what is the equivalent XML mapping? Why is it needed for a query only property? My assumption was that setting access to none or noop would prevent any changes.


Jamie

You can generate the hbms from your AutoPersistenceModel and have a look at the xml if you are still interested. Just something like

model.CompileMappings(); 
model.WriteMappingsTo(outputDir);

As an aside, have you had a look yet @ ConfOrm. I suspect this will gain increased traction given the dev, but haven't spent much time with it yet.

HTH,
Berryl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜