我写了这个查询:
var queryDetails = DbContext.ProductEventNotificationDetails.Where(p
=>p.ProductEventNotifications_Id == ID).ToList().Select(r => new
{
r.Id,
NotificationMethod =
r.NotificationContact.NotificationMethod.Name
});
因此,我只需要根据NotificationMethod值获取不同的值。如果我最后使用distinct(),它会根据Id进行调度。能告诉我如何实现这个目标吗?
答案 0 :(得分:1)
var queryDetails = DbContext.ProductEventNotificationDetails
.GroupBy(x => x.NotificationMethod)
.Select(group => group.Key);