views:

45

answers:

1

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

+2  A: 

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]]");
Mattias Jakobsson
grenade