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); と
- 特定の法案 (内部クエリ) と同じ委員会 (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_id
com_id
fnd_id