Asp.net mvc 尝试向LINQ语句添加左联接

Asp.net mvc 尝试向LINQ语句添加左联接,asp.net-mvc,linq,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 Syst

我想允许
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)
               };
var-previous=来自FindAllCustomerPayments中的g(对象CustomerId)
入会
关于g.CustomerBillId等于a.CustomerBillId
其中System.Data.Entity.DbFunctions.TruncateTime(g.TransactionDateTime)n.Credit)-p.Sum(n=>n.Debit)
};
你可以

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

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

好的,那么你的代码给了你什么?(为什么只为single customer ID属性创建一个新的匿名类型?只需将g.CustomerId分组到p中即可……)好的,那么您得到的代码给了您什么?(为什么只为single customer ID属性创建一个新的匿名类型?只需将g.CustomerId分组到p中即可…)