LINQ 左联查询 Left Join
C# 全选
//左连接,left join
var listSource = (from a in q
join b in q_AccountItems on a.AccountId equals b.ItemID into tmp
from b in tmp.DefaultIfEmpty()
select new
{
isid = a.isid,
YYYYMM = a.DocDate.Value.Year.ToString() + a.DocDate.Value.Month.ToString().PadLeft(2, '0'),
ItemId = a.AccountId,
ItemName = b != null ? b.ItemName : "",
Amount = a.ARAP == "收" ? a.Amount : (a.Amount ?? 0) * -1,//收:正数,支:负数
}).ToList();
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
CSFramework.EF C/S框架网