Skip to content

Map type with overrides

Cleve Littlefield edited this page Feb 1, 2016 · 1 revision

Let's say you have a type like this:

public class Client
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal TotalValue { get; set; }
}

But you have a stored procedure called spGetClients that returns Id, Name, but LifetimeValue instead of TotalValue. You don't have to map each field explicitely, you can map the type then override the one column that needs explicit mapping.

var clientMapDefinition = new MapDefinition(); clientMapDefinition.MapType(); clientMapDefinition.Map(model => model.TotalValue, "LifetimeValue");

Clone this wiki locally