Issue in non Generic Execute Method in DbLinq.Data.Linq.Implementation.QueryProvider

We´ve been working with DbLinq for a while now, at HexaSystems and recently using it together with Dynamic Linq and SQLite I programed a call to the Count method of a Queryable object as follows:

1
2
3
4
5
6
7
8
9
10
11
public static int Count(this IQueryable source)
{
    if (source == null) throw new ArgumentNullException("source"); 
    return (int)source.Provider.Execute(
        Expression.Call(
            typeof(Queryable), 
            "Count",
            new Type[] { source.ElementType },
            source.Expression));
}

I noticed that when doing so against a DbLInq Table object the following method is called:

1
2
3
4
public object Execute(Expression expression)
{
    .... }

the problem is that the function calls the generic Execute method inside the same class with the generic argument of type object: “Execute(expression)” which causes an invalid cast exception in the case I´m talking about, and potentially any call to this method could fail when the expression evaluation creates a generic type. I´ve submitted a patch to DBLinq developers and it was offically accepted: http://code.google.com/p/dblinq2007/source/detail?r=1224

Leave a Reply

Your email address will not be published. Required fields are marked *