I need to add Formula property/field on SubSonic | SimpleRepository Can someone tell me how to? or is it not possible?
br, No Body
I need to add Formula property/field on SubSonic | SimpleRepository Can someone tell me how to? or is it not possible?
br, No Body
Why not just do the calculation within the object definition itself?
So
public class OrderLine
{
public int OrderId { get; set; }
public int Qty { get; set; }
public decimal ProductPrice { get; set; }
public decimal LineCost
{
get { return Qty * Convert.ToDecimal(LineCost); }
}
}
Just add [SubSonicIgnore] to above LineCost
so
[SubSonicIgnore]
public decimal LineCost
{
get { return Qty * Convert.ToDecimal(LineCost); }
}
this is happening as LineCost is being mapped to the database.
I can only see a way by using anoynmous types, and then you will have to convert the type to the orderline (its not very nice)
var x =from o in repo.All<OrderLine>()
select new
{
OrderId = o.OrderId,
ProductPrice = o.ProductPrice,
Qty = o.Qty,
LineCost = o.ProductPrice * o.Qty
};
List<OrderLine> orders = null;
foreach (var t in x)
{
orders.Add(new OrderLine
{
LineCost = t.LineCost,
OrderId = t.OrderId,
ProductPrice = t.ProductPrice,
Qty = t.Qty
});
}