When this code gets called, I'm getting an error on
|| c.CustomerOrderNumber.Contains(query)
It runs ok if I comment out those two line in the code below.
public class PredispatchController : CommonController
{
protected object SearchOrders(string query, string sort, int page, int take)
{
int totalRows = (from c in _stockEntities.spM80PreDispatch()
where c.OrderNumber.Contains(query)
|| c.CustomerOrderNumber.Contains(query)
|| c.DName.Contains(query)
|| c.PartNo.Contains(query)
|| c.StockDesc.Contains(query)
select c).Count();
var results = (from c in _stockEntities.spM80PreDispatch()
where c.OrderNumber.Contains(query)
|| c.CustomerOrderNumber.Contains(query)
|| c.DName.Contains(query)
|| c.PartNo.Contains(query)
|| c.StockDesc.Contains(query)
select c).AsQueryable();
int skip = 0;
ViewData["pageLinks"] = Pagination.Paging("Search", page, totalRows, take, out skip);
return AddSortQuery(sort, results).Skip(skip).Take(take).ToList();
}
The full error is this:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
CELIntranet.Models.spM80PreDispatch_Result.CustomerOrderNumber.get returned null.
Am I to assume that it can't find the object called CustomerOrderNumber
from the returned spM80PreDispatch_Result
or
is it because some of the records in the CustomerOrderNumber
column has Null values?
I'm new to ASP.NET and C# and I am struggling with learning some of this stuff. Any help appreciated.