一个简单的查询语句
求多列的和
from c in fdc.cost
where c.date.Value.Month == month
select c.dinner ?? 0 + c.dress ?? 0 + c.living ?? 0 + c.medicine ?? 0 + c.secondary ?? 0 + c.sociality ?? 0 + c.study ?? 0 + c.traffic ?? 0 + c.unexpected ?? 0).Sum();
这样结果是不对的,应该怎么写呢?
------解决方案--------------------
C# code
//昨天其实就看到你的问题了!刚刚再次看到才想起来!
DataTestDataContext db = new DataTestDataContext();
var query1 = from p in db.News
select new
{
sum = db.News.Sum(o => o.NewsId+o.NewsState),
};