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]]");
精彩评论