Accepted answer

it is possible to change expression trees at runtime (by building a new one out of the existing one), since o/rm tools such as linq to sql and entity framework do this constantly, but it's not really easy. it has become easier with the introduction of the expressionvisitor class of .net 4.0, but still don't expect it to be simple.

here is an article that shows an example of this.


would it help to convert the query to an enumerable and call count() on this like this:

var num = query.asenumerable().count();

this would execute the query and afterwards makes a simple count() on the result instead of letting the count() flow into the expressiontree.

Related Query

More Query from same tag