我需要在SubSonic | SimpleRepository上添加公式属性/字段。有人能告诉我怎么做吗?或者这是不可能的?
br,无主体
发布于 2009-08-03 12:16:25
只需在上面的LineCost中添加SubSonicIgnore
所以
[SubSonicIgnore]
public decimal LineCost
{
get { return Qty * Convert.ToDecimal(LineCost); }
}这是在LineCost映射到数据库时发生的。
发布于 2009-08-03 11:00:58
为什么不直接在对象定义中进行计算呢?
所以
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); }
}
}发布于 2009-08-04 08:35:15
我只能通过使用无序类型找到一种方法,然后你必须将类型转换为orderline (这不是很好)
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
});
}https://stackoverflow.com/questions/1221151
复制相似问题