I am trying to create a LINQ query that will filter out data with criteria from two different columns.
I am trying to get data between two dates from Time_Data_1
column only when a specific string value is met from Section_Data
column,
ie,
Between 2016/5/15
and 2016/6/16
when SelectedOption = Something
This is what I have, which is not working.
DataGridOne.DataContext = sql.Time_TBLs.Where(item =>
item.Time_Data_1 < new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, 15) &&
item.Time_Data_1 > new DateTime(DateTime.Now.Year, DateTime.Now.Month, 16) &&
item.Section_Data == SelectedOption);
This query below works for the single criteria of getting data between two dates. But it picks up every bit of data between those dates.
Column1.DataContext = sql.Time_TBLs.Where(item =>
item.Time_Data_1 < new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, 15) &&
item.Time_Data_1 > new DateTime(DateTime.Now.Year, DateTime.Now.Month, 16)
How do add a second criteria to the query?
EDIT: Typo, supposed to && when I put &