【发布时间】:2015-08-06 12:33:08
【问题描述】:
我在这个问题上被困太久了,我认为这只是我的经验不足。我已经查看了许多类似的文章,但是当我将其应用于我的情况时似乎没有任何工作。
我在 EF6 中使用 linq 到实体。我有两个简单的表“LoanRepayment”和“LoanReceipt”。它们与从 LoanRepayment.LoanPaymentId 到 LoanReceipt.LoanPaymentId 的外国相关联。有 48 个固定贷款支付,其中 4 个有收据。我只想创建一个包含 48 行的表,其中包含 LoanRepayment 表中的所有 48 行以及存在的任何收据数据(即 4)。尚未支付的贷款旁边的其余单元格应为空白。
Dim queryLoanRepayments = (From lp In proxifundContext.LoanRepayments Group
Join lr In proxifundContext.LoanReceipts On lr.LoanPaymentId Equals
lp.LoanPaymentId Into paymentlist = Group From lr In
paymentlist.DefaultIfEmpty() Select lp.InstallmentNo, lp.InstallmentAmount,
lp.Penalty, lp.PaymentDate, If(lr.ReceiptDate Is Nothing, String.Empty,
lr.ReceiptDate), If(lr.Amount Is Nothing, String.Empty, lr.Amount)).ToList()
当我运行上面的查询时,intellisense 会在两条 If 语句中加下划线,并带有以下消息:“范围变量名称只能从不带参数的简单名称或限定名称中推断出来”。
我做错了什么?
【问题讨论】:
标签: vb.net linq-to-entities left-join