开发者

Mapping a property to an SQL expression or multiple columns in Fluent nHibernate

开发者 https://www.devze.com 2022-12-17 23:19 出处:网络
I have no control over the db schema and need to map two database columns to a single property in my .Net class. The db engine is DB2

I have no control over the db schema and need to map two database columns to a single property in my .Net class. The db engine is DB2

The database has columns AUTH_DT of type DATE and AUTH_TM of type TIME. The relevant code follows:

public class Authorisation{
    ...
    public virtual DateTime TransactionDate { get; set; }
    ...
}
public class AuthorisationMap : ClassMap<Authorisation>{
    ...
    Map(x => x.TransactionDate); //.Column("AUTH_DT" + "AUTH_TM");
    ...
}

How can I t开发者_Python百科ell the class-map to combine the date and time columns from the db?


There is a method called "Formula". This method takes a sql statement that will be mapped to the property. It will be written as a sub query in the sql statement. Used something like this:

Map(x => x.TransactionDate).Formula("[[sql statement]]");
0

精彩评论

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

关注公众号