I have a request:
var qq = (from c in db.tblArcadeGames where c.IsDeleted == false && c.ParentGameID == 0 && c.Approved == true let aggPlays = c.Plays + db.tblArcadeGames.Where(v => v.ParentGameID == c.ID).Sum(v => (int?)v.Plays) orderby aggPlays descending select new { c, aggPlays }) .Skip(Skip) .Take(Fetch); foreach (var g in qq) { HttpContext.Current.Response.Write("{" + g.aggPlays + "}\n"); }
When I type aggPlays
in the loop above, they exit like:
{21} {} {} {}
The problem is that Sum()
returns null
if there are no records. I'm not sure how to get around this so c.Plays + null
not null
, but just c.Plays
.
Tom gullen
source share