这是我的模型。
public class Notification
{
public int NotificationID { get; set; }
public bool ReadStatus { get; set; }
public DateTime DateCreated { get; set; }
[ForeignKey("User"), Column(Order=0)]
public int UserID { get; set; }
[ForeignKey("Actor"), Column(Order = 1)]
public int ActorID { get; set; }
[ForeignKey("NotificationType")]
public int NotificationTypeID { get; set; }
//public int ObjectID { get; set; }
[ForeignKey("Comment")]
public int? CommentID { get; set; }
[ForeignKey("Project")]
public int? ProjectID { get; set; }
[ForeignKey("Book")]
public int? BookID { get; set; }
public Comment Comment { get; set; }
public Book Book { get; set; }
public Project Project { get; set; }
public NotificationType NotificationType { get; set; }
public User User { get; set; }
public User Actor { get; set; }
}
任何给定的行将只有以下之一:BookID
,,
我想获得总通知的计数,但我必须按这三个 ID 之一对它们进行分组ProjectID
,其他两个 ID 为空。可能有 10 条评论通知,但其中 5 条用于回复,5 条用于其他操作 - 不过应该只有两条通知,而不是 10 条。CommentID
NotificationType
我将如何编写一个 lambda 表达式来获得这些计数?