0
string rep = "Joe Shmoe"

ObjectSet<StoreData> storeData = edmContext.StoreData;
ObjectSet<CallData> callData = edmContext.CallData;
IEnumerable<string> repStoreData = storeData.Where(r => r.RepName == rep).Select(s => s.Location);

IEnumerable<CallData> repCallData = Here is where I want to filter down the callData collection down to just the records that have a location that is contained in the repStoreData collection

私は何らかの形式の Join と Any を使用してみましたが、それらが求めている引数を本当に理解していません。

これは私の最善の試みであり、失敗です。

... = callData.Join(d => d.LOCATION.Any(repStoreData));

4

1 に答える 1

2

結合を使用する必要はありません。あなたはただ使うことができます:

callData.Where(d => repStoreData.Contains(d.LOCATION))

d.LOCATIONそれは単一の文字列であると仮定しています。

repStoreDataただし、現在のas -LINQの宣言ではおそらくそれを実行したくないでしょう- LINQ はそれをデータベースIEnumerable<string>で実行されるクエリに変換できません。

repStoreDataただし、 asと宣言できる場合はIQueryable<string>、うまく機能する可能性が高くなります。それが で動作するかどうかはわかりませんがObjectSet<T>、動作することを願っています。

于 2012-11-27T17:59:00.073 に答える