0

日時アイテムのリストを持つオブジェクトがあります。プロパティを持つ別のリストがあります

他のリストのアイテムの1つと一致する場合にのみ、オブジェクトにあるリストの日時アイテムを選択したいと思います。アイテムは入手できますが、基本的に「現在のアイテムがこのリストのいずれかのアイテムと一致するかどうか」の書き方がわかりません。

これまでのLINQは

from item in ObjectWithList.DateList
from compareItem in OtherDateTimeList
where item = //Here is there I run into trouble, how would I loop through the compareitems?

ありがとう

編集 これは全体的なLINQの一部にすぎないため、このLINQでこれを行う必要があります。

4

2 に答える 2

1
ObjectWithList.DateList.Intersect(OtherDateTimeList)

編集

Linq クエリである必要があり、Intersect を使用したくない場合は、これを試してください。

var mix = from f in ObjectWithList.DateList
          join s in OtherDateTimeList on f equals s
          select f;

また

var mix = from f in ObjectWithList.DateList
          from s in OtherDateTimeList 
          where f == s
          select f;
于 2012-09-14T16:28:28.470 に答える
0

Intersect標準クエリ演算子を使用できます。

var items = ObjectWithList.DateList.Intersect(OtherDateTimeList)
于 2012-09-14T16:28:44.493 に答える