Linq query with nullable sum

前端 未结 14 1892
粉色の甜心
粉色の甜心 2020-11-29 06:23
from i in Db.Items
select new VotedItem
{
    ItemId = i.ItemId,
    Points = (from v in Db.Votes
              where b.ItemId == v.ItemId
              select v.Poi         


        
14条回答
  •  Happy的楠姐
    2020-11-29 06:57

    Thought I would throw another solution out there. I had a similar issue and this is how I ended up solving it:

    Where(a => a.ItemId == b.ItemId && !b.IsPointsNull()).Sum(b => b.Points)
    

提交回复
热议问题