I have a method to add a date condition to my linq query. What I want to do is pass x.Due in as a parameter to make this able to work with any date. Any Ideas?
protected virtual IQueryable<TaskView> AddTaskDuePredicate( DateCriteria dateCriterion, IQueryable<TaskView> taskSummary )
{
if ( dateCriterion.Condition == DateCondition.LessThan )
taskSummary = taskSummary.Where( x => x.Due < dateCriterion.Value1 );
else if ( dateCriterion.Condition == DateCondition.LessThanOrEqualTo )
taskSummary = taskSummary.Where( x => x.Due <= dateCriterion.Value1 );
else if ( dateCriterion.Condition == DateCondition.GreaterThan )
taskSummary = taskSummary.Where( x => x.Due > dateCriterion.Value1 );
else if ( dateCriterion.Condition == DateCondition.GreaterThanOrEqualTo )
taskSummary = taskSummary.Where( x => x.Due >= dateCriterion.Value1 );
else if ( dateCriterion.Condition == DateCondition.EqualTo )
taskSummary = taskSummary.Where( x => x.Due == dateCriterion.Value1 );
else if ( dateCriterion.Condition == DateCondition.Between )
taskSummary = taskSummary.Where( x => x.Due <= dateCriterion.Value1 && x.Due >= dateCriterion.Value2 );
return taskSummary;
}