リストから除外する|スタート日|終了日のLINQのINステートメントは、私は2つのテーブル</p> <p><strong>契約</strong></p> <p>IDを持って
ExcludedContracts
同上| ContractID
私は両方のデータセットを取得するには、次のステートメントを使用しています:私はExcludedContractsテーブルのレコードを持っていないすべての契約を選択する必要が
var excludedContracts = from Excluded in
DataContext.ExcludedTransportContracts
select Excluded;
// Get a collection of all live sites first
var liveContracts = from Contracts in DataContext.Contracts
where Contracts.EndDate > DateTime.Now
select Contracts;
。私はしばらくの間WHEREのクエリと戦ってきたが、運がなかった。
私はinstatement IN(1,2,3)SQLと同様のクエリを実行するにはどうすればよいですか?
ありがとうございます!あなたもこの方法を除き、LINQを見るべきしかし
これは最高でした、私は関係を正しく設定しなかったので、今度はContracts - > ExcludedContractsになりますので、私はちょうどこれを行うことができます。 Contracts.contractEndDate> DateTime.Now && Contracts.ExcludedTransportContracts.Count()= = 0 – nik0lias
注: '!Contracts.ExcludedTransportContracts.Any()'は、Count == 0よりも効率的なSQLを証明します。 –
大変ありがとうございます。 – nik0lias