I have a WhereFilter property in a base class that looks like this:
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 the 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 an error, because WhereFilter is null (the object reference is not set to the object instance).
I am currently 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 property of the base class will be lost.
Any way to resolve this? In sql, I used a mannequin, where 1 = 1 piece, can this be done similarly here in linq?
c # linq
Umair
source share