我需要在SubSonic上添加Formula屬性/字段| SimpleRepository 有人能告訴我如何?或者不可能?SubSonic 3.0.0.3 | SimpleRepository |公式屬性/字段
BR, 否主體
我需要在SubSonic上添加Formula屬性/字段| SimpleRepository 有人能告訴我如何?或者不可能?SubSonic 3.0.0.3 | SimpleRepository |公式屬性/字段
BR, 否主體
只需添加[SubSonicIgnore]以上LineCost
所以
[SubSonicIgnore]
public decimal LineCost
{
get { return Qty * Convert.ToDecimal(LineCost); }
}
爲LineCost被映射到數據庫發生這種情況。
爲什麼不只是做對象定義本身的測算?
所以
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); }
}
}
,我只能看到使用anoynmous類型的方式,然後你將不得不類型轉換爲訂單行(它不是很漂亮)
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
});
}
感謝波奇,我會嘗試這一個。這是正確的方式還是隻是解決方法? – 2009-08-03 11:18:10
失敗:SQLEXCEPTION:無效的列名稱LineCost「 @Podge,記得我使用SimpleRepository和手工製作我的類/對象 – 2009-08-03 11:42:42