zoukankan      html  css  js  c++  java
  • LINQ多表连接查询

    var query = from et in _unitOfWork.Repository<EmployeeTarget>().Table
    join bra in _unitOfWork.Repository<BranchInfo>().Table
    on et.BranchCode equals bra.BranchCode
    into temp1
    from b in temp1.DefaultIfEmpty()
    join emp in _unitOfWork.Repository<EmployeeInfo>().Table
    on et.EmpCode equals emp.EmpCode
    into temp2
    from e in temp2.DefaultIfEmpty()
    where et.EtYear == searchCriterria.Year && et.EtMonth == searchCriterria.Month
    && et.TargetModuleId == searchCriterria.MId && et.BranchCode == searchCriterria.BranchCode
    orderby et.EmpCode ascending
    select new
    {
    et.EtId,
    et.EtYear,
    et.EtMonth,
    et.EtTargetValue,
    et.TargetModuleId,
    et.BranchCode,
    b.BranchName,
    et.EmpCode,
    e.EmpSaleCode,
    e.EmpName,
    e.PostName
    };

    var result = query.ToList().ConvertAll<EmployeeTarget>(item => new EmployeeTarget()
    {
    EtId = item.EtId,
    EtYear = item.EtYear,
    EtMonth = item.EtMonth,
    EtTargetValue = item.EtTargetValue,
    TargetModuleId = item.TargetModuleId,
    BranchCode = item.BranchCode,
    BranchName = item.BranchName,
    EmpCode = item.EmpCode,
    EmpSaleCode = item.EmpSaleCode,
    EmpName = item.EmpName,
    PostName = item.PostName
    });

  • 相关阅读:
    jenkins GitHub 自动触发
    rabbitmq web管理
    系统编码,文件编码,python编码
    反转二叉树
    从右边看二叉树
    python pyenv
    js 闭包
    git review & devops过程
    centos7搭建自己的yum源
    优先级队列PriorityQueue 测试,会自动排序
  • 原文地址:https://www.cnblogs.com/morpheusliu/p/9447711.html
Copyright © 2011-2022 走看看