3

このようなクエリで結合した2つのテーブルがあります

IQueryable<Auction> closed =
                (from a in CurrentDataSource.Auctions
                 join p in CurrentDataSource.Payments
                     on a.Id equals p.AuctionId
                 where <some condition>
                 select a);

私が本当に望んでいるのは、支払いテーブルとの結合がないか、何らかの条件が真あるすべてのオークションを私に与えることです。これはT-SQLで実行できますが、Linqで実行する方法がわかりません。手伝ってくれますか?

4

1 に答える 1

2

T-SQLの場合と同じように、左外部結合を使用して、支払いがnullであることを確認できます。

IQueryable<Auction> closed =
                (from a in CurrentDataSource.Auctions
                 join p in CurrentDataSource.Payments
                     on a.Id equals p.AuctionId into temp
                 from t in temp.DefaultIfEmpty()
                 where t == null && <some condition>
                 select a);
于 2012-10-19T15:27:17.420 に答える