zoukankan      html  css  js  c++  java
  • linq表达式 多表关联查询,左连接查询

    多表关联查询
                 from x in _wholesalerReplenishmentDetailRepository.GetAll()
                          join n in _wholesalerReplenishmentRepository.GetAll() on x.WholesalerReplenishmentId equals n.Id  //批发商补货
                          join y in _store.GetAll() on x.StoreId equals y.Id //店铺
                          join z in _wholesalerEmployeeRepository.GetAll() on x.EmployeeId equals z.Id into groupsz
                          from grpz in groupsz.DefaultIfEmpty() //业务员(可能为空)
                          join m in _wholesalerRepository.GetAll() on x.WholesalerId equals m.Id into groupsm
                          from grpm in groupsm.DefaultIfEmpty() //批发商(可能为空)
                          orderby x.CreationTime descending
                          select new WholesalerReplenishmentFullDto
                          {
                              Id = x.Id,
                              CompanyName = grpm.CompanyName,
                              EmployeeName = x.EmployeeId == null ? grpm.ContactPerson : grpz.EmployeeName,//可能批发商自己补货,//可能批发商自己补货,
                              StoreName = y.Name,
                              StoreBossName = y.BossName,
                              CreatTime = x.CreationTime,
                              CreationAddress = n.CreationAddress,
                              OpratorId = x.LastModifierUserId == null ? x.CreatorUserId : x.LastModifierUserId,
                              OpratorTime = x.LastModificationTime == null ? x.CreationTime : x.LastModificationTime,
                              ProductId = x.ProductId
                          };

    let设置临时条件

              from u in users
                 let number = Int32.Parse(u.Username.Substring(u.Username.Length - 1))
                 where u.ID < 9 && number % 2 == 0
                 select u
  • 相关阅读:
    分段、分页&&内存碎片、外存碎片
    mysql中的事务处理
    算法的在线演示网站
    为什么要使用树以及使用什么树
    平衡多叉树--B-Tree(B树)
    MVCC--多版本并发控制机制
    mysql中的锁
    平衡二叉树--红黑树(RB-Tree)
    平衡二叉树--AVL树
    自平衡方式--旋转
  • 原文地址:https://www.cnblogs.com/KQNLL/p/9871919.html
Copyright © 2011-2022 走看看