C#linq查询外部应用与总和

C#linq查询外部应用与总和,linq,sum,apply,outer-join,Linq,Sum,Apply,Outer Join,正在尝试将SQL查询转换为Linq: SELECT GrossInvoiceAmount, C.SumOfPayments FROM invoice OUTER APPLY( SELECT SUM(SumOfPayments) AS SumOfPayments FROM vw_sumOfPayments WHERE vw_sumOfPayments.PaymentDate = '01/01/2010 00:00:00' AND vw_sumOfPayments.Invoi

正在尝试将SQL查询转换为Linq:

SELECT GrossInvoiceAmount, C.SumOfPayments
  FROM invoice
OUTER APPLY(
  SELECT SUM(SumOfPayments) AS SumOfPayments FROM vw_sumOfPayments
  WHERE vw_sumOfPayments.PaymentDate = '01/01/2010 00:00:00'
      AND vw_sumOfPayments.InvoiceId = invoice.InvoiceId
) C
WHERE LastTransmitDate = '01/01/2010 00:00:00'
我的密码里有这个。它运行并给出结果,但是
invoice.GrossInvoiceAmount
金额错误。有什么想法吗?谢谢

var InvoiceQuery = (from invoice in this.Context.Invoices
        join payment in this.Context.vw_sumOfPayments.Where(pay => DbFunctions.TruncateTime(pay.PaymentDate) >= startdate 
                                        && DbFunctions.TruncateTime(pay.PaymentDate) <= enddate) 
                on invoice.InvoiceID equals payment.InvoiceID into pays
        select new InvoiceModel{

           InvoiceTypeId = invoice.InvoiceTypeId,
           InvoiceNumber = invoice.InvoiceNumber,
           InvoiceDate = invoice.InvoiceDate,
           InvoiceAmount = invoice.GrossInvoiceAmount,
           PaymentAmount = pays.AsEnumerable().Sum(o => o.SumOfPayments)

         });
var InvoiceQuery=(来自this.Context.Invoices中的发票
在这个.Context.vw_sumOfPayments.Where(pay=>DbFunctions.TruncateTime(pay.PaymentDate)>=startdate中加入payment
&&DbFunctions.TruncateTime(pay.PaymentDate)o.SumOfPayments)
});

应该提到。我想我缺少的是外部应用程序中的总和(付款总额)。那笔钱必须存在,否则总额就不对了。。。林克:什么?