Monday, July 3, 2017

Assigning to a variable a where clause in C# is, yes, a use case for a Func!

Assuming...

return myIQueryableSoFar.Where(MyStaticClass.MyStaticFunc);

 
 

We could call out to a static method in our static class named MyStaticClass which would look like this:

public static Expression<Func<MyQueriedType, bool>> MyStaticFunc
{
   get
   {
      return (x) => x.meatyCondition != null;
   }
}

No comments:

Post a Comment