我在我的应用程序中使用linq编写我的子查询。我在sql server中编写了我的sql子查询。当我在SQL Server中执行此查询时,结果将完美,sql查询将类似于
我的SQL Server:
~ipad
我的linq查询
select Row_Number() Over(OrderBy Mmname) as Sno,Mmname,Mmcardno,Mmdob,MmEmail,(Select SUM(MSSRNETAMT) from MSCAS where MSCAS.MSSFORMNO = MSMEM.MmCardno and MSCAS.MSSRBILLDT between '01/01/2016' and '30/12/2016') Billopen,(Select SUM(MSSRNETAMT) from MSCAS where MSCAS.MSSFORMNO = MSMEM.MmCardno and MSCAS.MSSRBILLDT between '01/01/2016' and '30/12/2016') BillForm,Mmredpv,Msdval,Mmcontact,Mmdate,Mmaddr,MmCuser,MmCuserdt,Mmusercd,
Mmuser,Mmuserdt,Cast(Mmcntrn as int ) as Mmcntr from MSMEM inner join MSSCHEDET on MSMEM.Mschuid = MSSCHEDET.MSDID
这只是我尝试了但是我在账单中收到错误这是我收到错误的金额
这是我的SQL查询。我试图在linq中转换此SQL查询。但我多次失败,我收到了错误。
答案 0 :(得分:0)
MSCAS
表吗?
var query = (from Ms in db.msmems
join Mss in db.Msschedet on Ms.Mechuid equals mss.MSDID
join Mc in db.MSCAS on Ms.Mmcardno equals Mc.Mssformno
select new {
name = Ms.Mmname,
Billopen = Mc.where(x=>x.MSSRBILLDT >= '01-01-2016' and x.MSSRBILLDT <= '12-30-2016').Sum(z=>z.MSSRNETAMT)
}
);