I have three tables which you can see in following diagram:
My problem is, I want to return all problems, its responses and the count of of seen status i.e. those responses which has not seen yet. I'm using Entity framework. I have used following query:
querySelection = (from problems in db.Problems
join response in db.Response on problems.Id equals response.QueryId
join order in db.Msg_Orders on response.Id equals order.Response_Id
join seen_status in db.Seen_Status on order.Order_Id equals seen_status.OrderId
select new QuerySelect{
Problem_State = problems.Problem_State,
Response = response.Response,
ResponseCount = /*What code should I write here*/
}).ToList();
I have 2 problems with my above query:
Expectation: It should return only unique problems and unseen response count
What result getting: As Msg_Orders have multiple problem Ids and above query returning same result multiple times
- Not understanding how to add count of unseen status inside above query.
