Starting with this code:
int Count(Func<MyClass, bool> conditions)
{
// ...
}
And I want to call it like so:
int c = Count(foo => foo.bar == 5 && !foo.blah);
How do I then write the count function so that it ends up like so:
int Count(Func<MyClass, bool> conditions)
{
// what goes here so that I get this:
string sql = "SELECT COUNT(*) FROM [MyClass] WHERE [Bar] = 5 AND [Blah] = 0"
// ... execute the sql etc.
}
For the purposes of this discussion, assume that I have already considered and rejected using LINQ to SQL or LINQ to Entities. Not looking for a pre-existing solution but an understanding of how this is done.