我正在正确获取数据。但我想获得 TotalRuns 即如果在 SQL Query 中,我可以将其写为
(SUM(pts.Run1)+SUM(pts.Run2)+SUM(pts.Run3)+SUM(pts.Run4)+Sum(pts.Run6)) As totalRuns
如何在 LINQ 中实现这一点?
我试过这个,但它给出了一个语法错误。
这是我的 LINQ 查询。
var playerScore = from pts in Oritia_entities.PlayerTeamSeasons
join p in Oritia_entities.Players on new { ID = pts.PlayerId }
equals new { ID = p.ID }
join c in Oritia_entities.Crews on new { ID = p.CrewId }
equals new { ID = c.ID }
join f in Oritia_entities.Fixtures on new { ID = pts.FixtureId }
equals new { ID = f.Id }
where c.ID == playerID && pts.SeasonId == seasonID
select new PlayerScore
{
BallsFaced = (int)pts.BallsFaced,
Run1 = (int)pts.Run1,
Run2 = (int)pts.Run2,
Run3 = (int)pts.Run3,
Run4 = (int)pts.Run4,
Run6 = (int)pts.Run6,
BallsBowled = (int)pts.BallsBowled,
RunsGiven = (int)pts.RunsGiven,
Wickets = (int)pts.Wickets,
Catches = (int)pts.Catches,
Dot = (int)pts.Dot,
NoBall = (int)pts.NoBall,
RunOutBy = (int)pts.RunOutBy,
// Match = (t1.T + " v/s " + f.Team2)
};
我正在使用.Net 4.0