I am trying to write a simple linq select query, where in the where clause the value is taken from a text box. I am having problem in case of datetime values. Now this works:
var rawData = contextSearch.GetType().GetProperty(TableName).GetValue(contextSearch, null);
truncatedData = ((IQueryable<object>)rawData).Where(columnName + ">=@0", DateTime.Parse(txtCrudSearch.Text)).ToList();
this also works for <=, but I need to find records for exactly the given date. So, when I try this:
truncatedData = ((IQueryable<object>)rawData).Where(columnName + "=@0", DateTime.Parse(txtCrudSearch.Text)).ToList();
It doesn't work. Why? How can I get this to work? FYI: columnname is taken from combobox dynamically and I'm using entity framework.