linq join group

 
 
var query = from de in dataContext.dispatchexception join d in dataContext.dispatch.Where(t => t.CreateTime >= startTime && t.CreateTime <= endTime && t.IsDeleted == 0 && (t.ShipperId == corpId || t.ConginerId == corpId || t.ReceiverId == corpId)) on de.dispatch_sn equals d.DispatchSN into j1 from j2 in j1.DefaultIfEmpty() group new { de, j2 } by de.exception_type into grouped select new { StatusType = grouped.Key, StatusCount = grouped.Count(t => t.j2.DId != null) };
 
 
 
 
 
 
 
  var reportQuery = from a  in  examReportTable.AsEnumerable()
                    join b  in  rvuTable.AsEnumerable()
                    on  new  { exam = a.Field< string >( "exam" ), examtype = a.Field< string >( "examtype" ) } equals  new  { exam = b.Field< string >( "rvuName" ), examtype = b.Field< string >( "rvuType" ) }
                    group b by  new  { reportDoc = a.Field< string >( "reportDoc" ), examtype = a.Field< string >( "examtype" ) } into c
                    select  new
                    {
                        DocName = c.Key.reportDoc,
                        examType = c.Key.examtype,
                        reportDocRvu = c.Sum(o =>  double .Parse(o.Field< string >( "reportRvu" ))),
                        reportDocNum = //examReportTable中对“exam”计数count这句怎么写?
                     };
 
 
 

猜你喜欢

转载自sangei.iteye.com/blog/2277524