gpt4 book ai didi

c# - Where 子句中的 LINQ 子查询在 LINQPad 中返回错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:37:39 25 4
gpt4 key购买 nike

在 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' 不包含 'application' 的定义,并且找不到接受类型为 'LINQPad.User.appSancAdvice' 的第一个参数的扩展方法 'application'(按 F4 添加using 指令或程序集引用)

后台的简要逻辑是只选择客户

  • 获得批准的建议 (status_id=4);和
  • 在申请表中有与特定法案(innerquery)相同的委员会(com_id)和基金(fnd_id)的记录



  • customer 实体与application

  • 相关
  • application 实体与advice

  • 相关
  • 但是,application实体与bill
    无关

更新

(表结构)

客户
客户编号

申请
应用程序编号
客户编号
com_id
fnd_id

建议
应用程序编号
状态编号

账单
账单编号
com_id
fnd_id

最佳答案

问题解决了。错误线路的正确导航路线是:

.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

关于c# - Where 子句中的 LINQ 子查询在 LINQPad 中返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18212529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com