I have a query that returns null reference exception
.
I'm filter data using searching, I put breakpoint and check that the problem is that when a column has a null value it returns exception
.
Controller:
if (searchValue != null || searchValue != "")
{
expheadlist = expheadlist.Where(e =>
e.Name.ToLower().Contains(searchValue) ||
e.Description.ToLower().Contains(searchValue)
).ToList<GenExpenseHead>();
}
I allowed null values in Description
attribute. This entity has a null value in Description
column. I think therefore it returns NullException
in this code. I don't know how to resolve it.
Thanks in Advance.