0
我試圖讓每個用戶的所有郵件的數量如何我可以通過我的全部郵件組
msg 1 = SenderId =1 , ReciverId =2
msg 2 = SenderId =2 , ReciverId =1
msg 3 = SenderId =1 , ReciverId =2
我在我的例子 考慮1個使用相同的用戶作爲一個消息聊天等等查詢需要reurn,我有一個消息
這是什麼查詢? 我寫了一個查詢底部,告訴我想要什麼 但是迴腸,我怎麼寫一個工作?
public class UserMessages
{
public long Id { get; set; }
public long SenderId { get; set; }
public long ReciverId { get; set; }
public string Text { get; set; }
public DateTime? DateTime { get; set; }
public bool FastMessage { get; set; }
public bool SenderDelete { get; set; }
public bool ReciverDelete { get; set; }
public bool ReciverRead { get; set; }
}
var UserMessages = db.UserMessages
.Where(x => (x.SenderId == id && x.SenderDelete == false) ||
(x.ReciverId == x.Id && x.ReciverDelete == false))
.GroupBy(x => new { x.ReciverId, x.SenderId })
.GroupBy((y, w) => y.Key.SenderId == w.Key.ReciverId
&& y.Key.ReciverId == w.Key.SenderId)
.Count();
究竟你到底想要得到什麼? –