public class Filter
{
public List<int> A { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
}
var f1 = new Filter(){A = new List<int>() {1}}
var f2 = new Filter(){A = new List<int>() {1 , 4, 2}, Start = DateTime.Now, End = DateTime.AddHour(2)}
var dict = new Dictionary<Filter, string>()
dict.Add(new Filter(){A = new List<int>() {1}}, "asdf");
dict.Add(new Filter(){A = new List<int>() {4}}, "qwerty");
dict.Add(new Filter(){A = new List<int>() {3}}, "qwertyasd");
私は取得する必要があります:
最初のf1アイテムで
1番目と2番目のf2アイテムで。
linqクエリを作成する方法は?
の場合、それAはint簡単です
dict.Where(k =>
k.Key.A.Equals(filter.A)
&& k.Key.Start.CompareTo(filter.Start) > 0
&& k.Key.End.CompareTo(filter.End) < 0
)
しかし、そうでない場合List<int>は、私にとってはもっと複雑です。