Can you do Compiled Queries with LINQ?

Posts   
 
    
gfunny
User
Posts: 20
Joined: 21-Apr-2005
# Posted on: 27-Nov-2009 21:50:38   

Is it possible to do this ?

public partial class NorthwindDataContext { public static Func<NorthwindDataContext, int, IQueryable<Product>> ProductsByCategoryID = CompiledQuery.Compile ((NorthwindDataContext context, int categoryID) => context.Products.Where(p => p.CategoryID == categoryID));

public IQueryable<Product> GetProductsByCategoryIDFast(int                                                      categoryID)
{
    return ProductsByCategoryID(this, categoryID);
}

}

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Nov-2009 07:47:09   

Hi there, could you please elaborate more? What for is all that?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 28-Nov-2009 10:45:43   

We don't need compiled queries because our query producing pipeline is very quick (way below 1ms). MS uses compiled queries because their linq provider is often very slow (15-20ms for producing a query) in more complex queries, and the projection pipeline doesn't use projection code using generic classes but generated IL to perform the projection.

Frans Bouma | Lead developer LLBLGen Pro