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");
I need to get:
with f1
item first
with f2
items first and second.
How to construct linq query?
When A
is int
, It's simple
dict.Where(k =>
k.Key.A.Equals(filter.A)
&& k.Key.Start.CompareTo(filter.Start) > 0
&& k.Key.End.CompareTo(filter.End) < 0
)
but when it ist List<int>
it's more complicated for me.
Just use Contains and invert the control