2

在 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

4

1 回答 1

1

它得到了解决。错误线路的正确导航路线是:

.Where(e => innerquery.Any(a => a.com_id == e.customer.application.com_id)) // exception at this line
.Where(e => innerquery.Any(a => a.fnd_id == e.customer.application.fnd_id))

错误是由于e.advice.application

于 2013-08-13T15:40:51.973 回答