欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

linq 多表分组左连接查询查询统计

程序员文章站 2023-02-18 12:25:10
return (from merchantsInfo in base.GetIQueryable(x => x.IsLogicDelete == false && x.FID != fid) join userAccount in UserAccountDal.GetIQueryable(x => ......
return (from merchantsinfo in base.getiqueryable(x => x.islogicdelete == false && x.fid != fid)
                    join useraccount in useraccountdal.getiqueryable(x => x.privilegelevel > 0)
                    on merchantsinfo.useraccountid equals useraccount.fid
                    join merchantsfrom in merchantsinfoformdal.getiqueryable(x => !x.islogicdelete)
                    on merchantsinfo.fid equals merchantsfrom.merchantsinfoid into data
                    from merchants in data.defaultifempty()
                    group new { merchants.merchantsinfoid } by new
                    {
                        merchantsinfo.fid,
                        merchantsinfo.name,
                        merchantsinfo.brandlabel,
                        merchantsinfo.mainpicture,
                        merchantsinfo.merchantsamountmax,
                        merchantsinfo.merchantsamountmin,
                        merchantsinfo.merchantsamounttype,
                        merchantsinfo.projectname,
                        merchantsinfo.belongindustry,
                        merchantsinfo.belongindustrychild,
                        merchantsinfo.merchantsarea,
                        merchantsinfo.merchantsareacity,
                        merchantsinfo.merchantsareacitysubset,
                        merchants.merchantsinfoid
                    } into g
                    select new merchantsmodel
                    {
                        fid = g.key.fid,
                        name = g.key.name,
                        brandlabel = g.key.brandlabel,
                        mainpicture = g.key.mainpicture,
                        merchantsamountmax = g.key.merchantsamountmax,
                        merchantsamountmin = g.key.merchantsamountmin,
                        merchantsamounttype = g.key.merchantsamounttype,
                        projectname = g.key.projectname,
                        belongindustry = g.key.belongindustry,
                        belongindustrychild = g.key.belongindustrychild,
                        merchantsarea = g.key.merchantsarea,
                        merchantsareacity = g.key.merchantsareacity,
                        merchantsareacitysubset = g.key.merchantsareacitysubset,
                        applynum = g.key.merchantsinfoid == null ? 0 : g.count()
                    }).take(row).tolist();