LINQ to SQL complex query
I have the following object
public Cell {
public string CategoryId {get; set;}
public DateTime FromTime {get; set}
public DateTime ToTime {get; set}
}
I have a DB table that is called Item that looks like this:
Item
-------------------------
CategoryId LastUpdated
Now in the code I have a list of Cell List<Cell> ToBeFetchedFromDB that
contains more than one Cell, suppose the list contains Foo and Bar, I want
to dynamically build a query like this BY INTERATING THROUGH THE
COLLECTION ToBeFetchedFromDB WITHIN MY LINQ TO SQL QUERY instead of
statically constructing the query:
from x in Item
where x.CategoryId == Foo.CategoryId && Foo.FromTime < x.LastUpdated <
Foo.ToTime
|| x.CategoryId == Bar.CategoryId && Bar.FromTime < x.LastUpdated <
Bar.ToTime
select x
I have been trying but can't figure it out :(
Thanks guys!
No comments:
Post a Comment