其他分享
首页 > 其他分享> > EF Core左连接内连接

EF Core左连接内连接

作者:互联网

内连接查两张表
from oo in query  
join comany in _companyRepository.GetAll() on oo.OfflineOrder.CompanyId equals comany.Id 
where comany.IsFamous 
select oo;

Lamad内连接
_storeRepository.GetAllIncluding().Join(_storeSupplierExtRepository.GetAllIncluding(), sr => sr.Id, sre => sre.StoreId, (sr, sre) => new { sr, sre }).FirstOrDefault(x => x.sr.StoreName == supplier.SupplierName);

左连接
from oo in query 
join mal in _exmailRepository.GetAll().Where(u => u.VipEndTime > DateTime.Now) on oo.OfflineOrder.CompanyId equals mal.CompanyId 
into malTemp 
from malJoin in malTemp.DefaultIfEmpty()

Lamad左连接
var query =_recommendStoreRepository.GetAll()
               .GroupJoin(_userRepository.GetAll()
               , rec => rec.RecommendUserId
               , user => user.Id
               , (rec, user) => new { rec, user = user.FirstOrDefault() })
               .WhereIf(input.OfflineOrderId > 0, m => m.rec.OfflineOrderId.Equals(input.OfflineOrderId))
               .ToListAsync();

 

标签:oo,Core,GetAll,sre,sr,EF,user,rec,连接
来源: https://www.cnblogs.com/opts/p/15213853.html