I have a WhereFilter property in a base class which is as follows:
public virtual Expression<Func<CustomerCustomerType, bool>> WhereFilter
{
get { return null; }
}
When it is overridden I want to return something else instead of null so I can use predicatebuilder extension And (from LinqKit) so I can write my code as follows:
public override Expression<Func<CustomerCustomerType, bool>> WhereFilter
{
get { return base.WhereFilter.And(x => x.CustomerID == 1); }
}
But this gives error as WhereFilter is null (Object reference not set to an instance of an object).
Currently I am writing as:
public override Expression<Func<CustomerCustomerType, bool>> WhereFilter
{
get { return x => x.CustomerID == 1; }
}
So when there is another child class overriding this, the base class property will be lost.
Any way to resolve this? In sql what I did was use a dummy where 1=1 thingy, can this be done similarly here in linq?