3

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?

1 Answer 1

2

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]]");
Sign up to request clarification or add additional context in comments.

1 Comment

Cool. Looks like just what I need. I just need to work out the syntax for my date & time combination now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.