Linq的Bug?计算合计报错,LinqPad却可通过.
winxp + .net3.5 sp1 + vs2008 sp1 + sql2000 这样可以通过:
var q = from t in this.erpDb.exp_t_detail
where t.exportdate >= this.dateTimePicker1.Value.Date && t.exportdate < dateEnd
orderby t.dtl_no
select new
{
dtl_no = t.dtl_no.Trim(),
dtl_date = t.exportdate.Value,
client_id = (from c in erpDb.exp_t_client where c.client_id == t.client_id select c.client_shortname.Trim()).FirstOrDefault(),
amount = erpDb.exp_t_detail_bggoods.Where(s => s.dtl_no == t.dtl_no && s.bgcomp_id == 415527 && (s.amt ?? 0) > 0).Sum(s => s.amt??0), //NND,这样子报sql执行错误
};
但同样的语句在LinqPad中执行通过!
不得以amount子句改成这样子:
amount = (erpDb.exp_t_detail_bggoods.Where(s => s.dtl_no == t.dtl_no && s.bgcomp_id == 415527 && (s.amt ?? 0) > 0).Sum(s => s.amt)) ?? 0
大家也碰上过这类莫名其妙的问题?
------解决方案--------------------
sp1后的linq不允许Sum(s => s.amt??0)了