简体   繁体   中英

FluentNHibernate Formula Mapping C#

Is there a way to declare a map passing a Formula which will run just for a specific statement ( SELECT in my case) ?

The problem is that I have something like

Map(x => x.Id).Formula("SUBSTRING(id, 0, 2)");

But it's causing errors when I try to run an insert for this specific entity, because it's using the Formula for the insert statement as well.

We have to make such column readonly

Map(x => x.Id)
    .Formula("SUBSTRING(id, 0, 2)")
    .ReadOnly();

or more like original insert="false" udpate="false"

Map(x => x.Id)
    .Formula("SUBSTRING(id, 0, 2)")
    .Not.Update()
    .Not.Insert();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM