sql语句转成linq 求大神帮忙转成linq

select count(rd.package_id) packageCount,
       sum(e.total_activity) as totalActivity,
       sum(m.diamerter / 2 * m.diamerter / 2 * m.height) as totalVolumn
  from RWIS_NUCLEAR_RUB_RECEPTION_D RD
 inner join RWIS_NUCLEAR_RUB_RECEPTION R
    on rd.recept_id = r.recept_id
 inner join rwis_nuclear_bucket b
    on rd.bucket_id = b.bucket_id
 inner join RWIS_BASIC_MATERIAL m
    on b.material_id = m.material_id
 inner join RWIS_NUCLEAR_APPLY_DETAIL d
    on rd.bucket_id = d.bucket_id
 inner join RWIS_DISPSITE_CHECK_DETAIL c
    on d.apply_detail_id = c.apply_detail_id
  left join RWIS_DISPSITE_EVAL e
    on c.detail_id = e.check_detail_id
 where r.status = '2'
   and r.stationcode = 'CC' and r.reception_date>='' and r.reception_date<='' 

1个回答

我自己写的但是不对

var nuclearRubReceptionDs = _currentUnitOfWork.NuclearRubReceptionDs.AsQueryable();
var nuclearRubReceptions = _currentUnitOfWork.NuclearRubReceptions.AsQueryable();
var nuclearBucket = _currentUnitOfWork.NuclearBuckets.AsQueryable();
var materialType = _currentUnitOfWork.MaterialTypes.AsQueryable();
var nuclearApplyDetail = _currentUnitOfWork.NuclearApplyDetails.AsQueryable();
var dispsiteCheckDetail = _currentUnitOfWork.DispsiteCheckDetails.AsQueryable();
var dispsiteEval = _currentUnitOfWork.DispsiteEvals.AsQueryable();

            var query = from rd in nuclearRubReceptionDs
                        join r in nuclearRubReceptions on rd.ReceptId equals r.ReceptId
                        join b in nuclearBucket on rd.BucketId equals b.BucketId
                        join m in materialType on b.MaterialId equals m.MaterialId into m
                        join d in nuclearApplyDetail on rd.BucketId equals d.BucketId
                        join c in dispsiteCheckDetail on d.ApplyDetailId equals c.ApplyDetailId
                        join e in dispsiteEval on c.DetailId equals e.CheckDetailId into eEmpt
                        from e in eEmpt.DefaultIfEmpty()
                        select new WasteStatisticView
                        {
                            Code = "",
                            TotalActivity = eEmpt.Sum(t => t.TotalActivity),
                            TotalVolume = m.Sum(mm=>mm.Diamerter/2*mm.Diamerter/2*mm.Height),
                            TotalCount = rd.PackageId.Count(),
                            Stationcode=r.Stationcode,
                            CreateDate =r.CreateDate
                        };
            return query;
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问