1 回答

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊
為了實(shí)現(xiàn)目標(biāo),需要在實(shí)體框架語法中使用GROUP BY
子句。INNER JOIN
我寫了以下解決方案來解決上述問題:
querySelection = (from problems in db.Problems
? ? ? ? ? ? ? join response in db.Response on problems.id equals response.Query_Id
? ? ? ? ? ? ? join order in db.Msg_Orders on query.id equals order.query_id
? ? ? ? ? ? ? join seen_status in db.Seen_Status on order.Order_id equals seen_status.Order_id
? ? ? ? ? ? ? group new { problems, response, order ,seen_status }
? ? ? ? ? ? ? ? by new
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? problems.Id,
? ? ? ? ? ? ? ? ? ? problems.Problem_State,
? ? ? ? ? ? ? ? ? ? problems.Created_Date,
? ? ? ? ? ? ? ? ? ? response.Response,
? ? ? ? ? ? ? ? ? ? seen_status.User_Seen_Status
? ? ? ? ? ? ? ? } into grp
? ? ? ? ? ? ? orderby grp.Key.Id descending
? ? ? ? ? ? ? select new QuerySelection
? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? Id = grp.Key.Id,
? ? ? ? ? ? ? ? ? Problem_State = grp.Key.Problem_State,
? ? ? ? ? ? ? ? ? Created_Date = grp.Key.Created_Date,
? ? ? ? ? ? ? ? ? Response = grp.Key.Response,
? ? ? ? ? ? ? ? ? TotalResp = grp.Count(x => x.seen_status.user_seen == 0) // Counting total number of responses
? ? ? ? ? ? ? }
? ? ? ? ? ? ? ).ToList();
- 1 回答
- 0 關(guān)注
- 141 瀏覽
添加回答
舉報(bào)