I have the following LINQ statement that does on where
on the date
and a LabID
.
I\'m passing in a list of LABS and a date, however
You need to check if your values are null before doing the query, and if they are, don't do the extra condition.
List lstDatExp =
(from l in ctx.dExp.Include("datLab")
where
(values == null || values.Contains(l.datL.Lab_ID)) &&
(reportingPeriod == null || l.reportingPeriod == reportingPeriod)
select l).ToList();
This way if values
or reportingPeriod
are null they are essentially optional.