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

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

There are AUTH_DTtype DATEand AUTH_TMtype columns in the database TIME. The appropriate code should be:

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 tell the map class to combine the date and time columns from db?

+3
source share
1 answer

There is a method called Formula. This method accepts an sql statement that will be mapped to this property. It will be written as a subquery in the sql statement. Something like this is used:

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

Source: https://habr.com/ru/post/1729098/


All Articles