VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > 简明python教程 >
  • linq 多表分组左连接查询查询统计

复制代码
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();
复制代码

 

如果有错误的地方,请帮我纠正。哈哈一起加油陌生人!!

相关教程