私は、Except 演算子と比較を使用して Linq で比較する方法の例をいくつか見てきましたが、それらはすべて、2 つの単純な型または 1 つの単純な型と 1 つの複合体でどのように行われるかを示しているように見えました。異なるタイプの 2 つのリストがあります。子プロパティに基づいて結果を選択し、プロパティが一致しているDateTime
がより新しい別のグループを選択する必要があります。誰でもこれで私を助けることができますか?
public class Parent
{
public List<Child> ChildList;
}
public class Child
{
public string FoodChoice;
public DateTime FoodPick;
}
public class Food
{
public string FoodName;
public DateTime FoodPick;
}
public void FoodStuff
{
var parent = new Parent();
var childList = new List<Child>();
childList.Add( new Child {FoodChoice="a",DateTime=.....
childList.Add( new Child {FoodChoice="b",DateTime=.....
childList.Add( new Child {FoodChoice="c",DateTime=.....
parent.ChildList = childList;
var foodList = new List<Food>();
foodList.Add......
var childrenWithNoMatchingFoodChoices = from ufu in Parent.ChildList where !Parent.ChildList.Contains ( foodList.FoodName )
var childrenWithMatchingFoodChoicesButWithNewerFoodPick = from foo in Parent.ChildList where Parent.ChildList.FoodPick > foodList.FoodPick
}
List<Child>
forを取得する方法を理解しようとしていchildrenWithNoMatchingFoodChoices
ます。List<Child>
forを取得する方法を理解しようとしていますchildrenWithMatchingFoodChoicesButWithNewerFoodPick
ヘルプ?.NET Framework 4.0 を使用しています。
ありがとう。