csharp 具有多个过滤器和连接的Linq查询

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 具有多个过滤器和连接的Linq查询相关的知识,希望对你有一定的参考价值。

var baseData = await q.Skip(request.SkipCount).Take(request.MaxResultCount).ToListAsync();

var q2 = from t in baseData

join a in await _customerManager.GetAllAgentFromCacheAsync() on t.OldAgentCode equals a.MustKod into oldAgent
from a in oldAgent.DefaultIfEmpty()

join aNew in await _customerManager.GetAllAgentFromCacheAsync() on t.NewAgentCode equals aNew.MustKod into newAgent
from aNew in newAgent.DefaultIfEmpty()

join p in _planRepository.GetAll() on t.PlanId equals p.Id into plan
from p in plan.DefaultIfEmpty()

join pr in _productRepository.GetAll() on t.ProductId equals pr.Id into product
from pr in product.DefaultIfEmpty()

join ph in _customerManager.GetAllMusteri() on
new { MustKod = t.PolicyHolderMustKod, KaynakKodu = t.OldSourceCode, SubeKod = t.OldBranchCode }
equals
new { ph.MustKod, ph.KaynakKodu, ph.SubeKod } into holder
from ph in holder.DefaultIfEmpty()

select new AgencyPortfolioTransferDto()
{
   Id = t.Id,
   OldAgentName = a?.Isim,
   NewAgentName = aNew?.Isim,
   ProductName = pr.ToString(),
   PlanName = p?.DisplayNameWithIdAndCode,
   MustKod = t.PolicyHolderMustKod,
   PolicyHolderName = t.PolicyHolderMustKod,
   StartDate = t.StartDate,
   EndDate = t.EndDate,

};

以上是关于csharp 具有多个过滤器和连接的Linq查询的主要内容,如果未能解决你的问题,请参考以下文章

具有多个 where 子句的 Linq to Datatable

CSharp使用另一个列表及其嵌套列表过滤带有LINQ查询的列表

PostgreSQL 中具有特定模式的 Linq 和实体迁移

LINQ

LINQ:具有多个条件的左外连接

具有 Lightswitch 计算属性的 Linq to SQL 查询过滤器