I have a simplified version of dynamic main query as follows :
var items = context.itemsGalore.Where(where).ToList();
The where for the Where condition is built dynamically as below.
if(compare == "Greater")
{
where = String.Format("{0} > {1}", DueDate, DateTime.ParseExact(dtValue.ToShortDateString(), "MM/dd/yyyy", CultureInfo.InvariantCulture));
}
else if(compare == "Lesser")
{
where = String.Format("{0} < {1}", field, DateTime.ParseExact(dtValue.ToShortDateString(), "MM/dd/yyyy", CultureInfo.InvariantCulture));
}
However I am getting the following error : Operator '<' incompatible with operand types 'DateTime' and 'Int32'
How do I go about fixing the issue?