尝试将左连接添加到LINQ语句

时间:2016-05-17 08:04:44

标签: asp.net-mvc linq

除了现有逻辑之外,我想允许g.CustomerBillId撤回空值。

var previous = from g in FindAllCustomerPayments(obj.CustomerId)
               join a in custPay                               
               on g.CustomerBillId equals a.CustomerBillId
               where System.Data.Entity.DbFunctions.TruncateTime(g.TransactionDateTime) <= previousBill.EffectiveDate   
               group g by new
               {
                   CustomerId = g.CustomerId

               } into p
               select new
               {
                   p.Key,
                   previousBalance = p.Sum(n => n.Credit) - p.Sum(n => n.Debit)
               };

1 个答案:

答案 0 :(得分:0)

你可以

from a in custPay.where(cust => cust.CustomerBillId = g.CustomerBillId).DefaultIfEmpty()