I have the following method but when I invoke that method I get a NullReferenceException.
public IQueryable<TItem> Query {get; set;}
public void AddCriteria<TSource>(TSource source, Func<IQueryable<TItem>, TSource, IQueryable<TItem>> func, Predicate<TSource> condition)
{
if(condition(source))
{
Query = func(Query, source);
}
}
I call it using the following line of code.
searchFilter.AddCriteria(searchCriteria, (u,v) => u.Where(p=>p.Field1.equals(true)), p => p.Field2.Specified && p.Field2.Name.Equals(Settings.Default.NameKey));
I'm trying to have a null safe check before apply the condition to the source. Do you know how to do it?
Thank you.