Linq to Sql 中 Sum 语句内的 IsNull
我正在尝试将一些 SQL 更改为 Linq-to-Sql,但是我在 SQL 中有以下行,我不确定如何转换:
SUM(Quantity * IsNull(ExchangeRate,1) * Factor )
所以到目前为止,我已经将分组 Linq 编写如下:
var items = from item in _dataContext.GetTable<Trade>()
group item by new {item.Curve}
into grp
select new Model.Position
{
Curve = grp.Key.Curve,
Value = ... "That line here"
};
return item
我想使用 let 关键字,并尝试使用 grp.Sum 都遇到了困难,因为查询中存在 IsNull 。
任何转换此查询的帮助将不胜感激!
理查德
I'm trying to change some SQL into Linq-to-Sql, however I have the following line in SQL that I'm not sure how to convert:
SUM(Quantity * IsNull(ExchangeRate,1) * Factor )
So I've so far written the grouping Linq as follows:
var items = from item in _dataContext.GetTable<Trade>()
group item by new {item.Curve}
into grp
select new Model.Position
{
Curve = grp.Key.Curve,
Value = ... "That line here"
};
return item
I've thought of using the let keyword, and tried using grp.Sum have struggled as there's the IsNull in the query.
Any help converting this query would be greatly appreciated!
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
盲打(没有智能感知:D),但以下应该有效:
Typing blind (without intellisense :D) but the following should work: