在 LINQPad 中执行以下查询时:
var innerquery = Bills.Where(e => e.id == 15);
var entity = Customer
.Join(applications, cust => cust.cust_id, app => app.cust_id,
(cust, app) => new { Customer = cust, application = app })
.Join(advices, cust => cust.application.app_id, sa => sa.app_id,
(cust, sa) => new { Customer = cust, advice = sa })
.Where(x => x.advice.status_id == 4)
.Where(e => innerquery.Any(a => a.com_id == e.advice.application.com_id)) // exception at this line
.Where(e => innerquery.Any(a => a.fnd_id == e.advice.application.fnd_id))
.Select(x => x.Customer.Customer.cust_id);
entity.Dump();
它在 LINQPad 中以异常结束:
“LINQPad.User.appSancAdvice”不包含“应用程序”的定义,并且找不到接受“LINQPad.User.appSancAdvice”类型的第一个参数的扩展方法“应用程序”(按 F4 添加 using 指令或程序集引用)
幕后的简要逻辑是只选择客户
- 获得批准的建议(status_id=4);和
- 在申请表中具有与特定法案 (innerquery) 相同的委员会 (com_id) 和基金 (fnd_id) 的记录
customer
实体与application
application
实体与advice
- 但是,
application
实体与bill
更新
(table structure)
客户
cust_id
应用程序
app_id
cust_id
com_id
fnd_id
建议
app_id
status_id
bill
bill_id
com_id
fnd_id