如何在noticeID上使用group by子句来选择linq中的所有这些字段 [英] how to use group by clause on the noticeID to select all these field in linq

查看:218
本文介绍了如何在noticeID上使用group by子句来选择linq中的所有这些字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var  notice =( from  n  context.Notice 
join nd 上下文中。 NoticeDetail
on n.ID等于nd.NoticeID
其中 nd.SenderLocationID == locationID&& nd.SenderActionID == sent& & nd.Title!=
选择 new
{
NoticeID = nd.NoticeID,
NoticeDetailID = nd.ID,
From =(currentLanguage == enmLanguage.English)?nd.SenderPanchaya tiRajLocation.Name:nd.SenderPanchayatiRajLocation.NameRegional,
Subject = nd.Title,
Date = nd.CreatedOn,
Priority =(currentLanguage == enmLanguage.English)? n.Priority.Name:n.Priority.Name_Regional,
SentMail = context.NoticeRecipients.Where(a = > a.NoticeDetailID == nd.ID ).Count(),
回复= context.NoticeRecipients.Where(a = > a.ReceiverLocationID == locationID&&(a.ReceiverActionID ==收到|| a.ReceiverActionID == read)&& a.NoticeDetail.NoticeID == nd.NoticeID).Count()

})。Distinct();

notice = notice.OrderBy(s = > s.Priority).ThenBy(s = > s.Date);
PagingBar1.Bind(注意, ref gvReceive);

解决方案

< blockquote>对不起,但不清楚你在问什么?

var gitms = notice.GroupBy(g => g.NoticeID);


var notice = (from n in context.Notice
                              join nd in context.NoticeDetail
                              on n.ID equals nd.NoticeID
                              where nd.SenderLocationID == locationID && nd.SenderActionID == sent && nd.Title !=""
                              select new
                                 {
                                     NoticeID = nd.NoticeID,
                                     NoticeDetailID = nd.ID,
                                     From = (currentLanguage == enmLanguage.English) ? nd.SenderPanchayatiRajLocation.Name : nd.SenderPanchayatiRajLocation.NameRegional,
                                     Subject = nd.Title,
                                     Date = nd.CreatedOn,
                                     Priority = (currentLanguage == enmLanguage.English) ? n.Priority.Name : n.Priority.Name_Regional,
                                     SentMail = context.NoticeRecipients.Where(a => a.NoticeDetailID == nd.ID).Count(),
                                     Replies = context.NoticeRecipients.Where(a => a.ReceiverLocationID == locationID && (a.ReceiverActionID == received || a.ReceiverActionID == read) && a.NoticeDetail.NoticeID == nd.NoticeID).Count()
                                 
                                 }).Distinct();
               
                notice = notice.OrderBy(s => s.Priority).ThenBy(s => s.Date);
                PagingBar1.Bind(notice, ref gvReceive);

解决方案

Sorry, but not clear what you are asking?
var gitms = notice.GroupBy(g => g.NoticeID);


这篇关于如何在noticeID上使用group by子句来选择linq中的所有这些字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆