0

次の 2 つのクエリがあります。

  1. 最初のものは、識別子の個別のリストを取得します。
  2. 2 番目は、これらの ID で結果をフィルタリングします。

        var query = (from bk in context.BookKeeping
                     join bk12 in context.BookKeeping on bk.LetteringId equals bk12.LetteringId 
                     into bk11
                     from bk1 in bk11.DefaultIfEmpty()
                     join bi2 in context.BillingInformation on bk1.BillingInformationId equals bi2.BillId 
                     into bi1
                     from bi in bi1.DefaultIfEmpty()
                     where bk.LetteringId != null && bk.PaymentId != null && bk1.LetteringId != null
                     select bk.PaymentId).Distinct();
    
        var query2 = from m in context.Movement
                     join p2 in context.Payment on m.PaymentId equals p2.Id
                     into p1
                     from p in p1.DefaultIfEmpty()
                     join pm2 in context.PaymentMode on p.PaymentModeId equals pm2.Id
                     into pm1
                     from pm in pm1.DefaultIfEmpty()
                     from ids in query
                     where ids.Value == p.Id
                     select m;
    

2 番目のクエリの興味深い部分は次のとおりです。

                 from ids in query
                 where ids.Value == p.Id

よりコンパクトにできるかどうか、およびメソッド構文を使用して条件付きで ID のリストをフィルタリングする方法を知りたいです。SelectManyを使用する必要があることは理解していますが、適切なオーバーロードを選択する方法がわかりません。

ティア。

4

1 に答える 1