I have a method that needs to conditionally execute a method, something like this:
int MyMethod(Func<int> someFunction)
{
if (_someConditionIsTrue)
{
return someFunction;
}
return 0;
}
I want to be able to pass a Linq query in to MyMethod as someFunction:
int i = MyMethod(_respository.Where(u => u.Id == 1).Select(u => u.OtherId));
How do I do this?