linq.compiledquery

Compiled queries and "Parameters cannot be sequences"

I thought that compiled queries would perform the same query translation as DataContext. Yet I'm getting a run-time error when I try to use a query with a .Contains method call. Where have I gone wrong? //private member which holds a compiled query. Func<DataAccess.DataClasses1DataContext, List<int>, List<DataAccess.TestRecord>> com...

Do Compiled Queries Cache?

Much of my application uses complied queries to retrieve data. In these queries I'll often refer to the current user. I'm noticing that if a user, B, logs in after another user, A, then user B will see user A's informaiton. I have querries much like this all through out the application public static Func<DataContext, MyRecord> CurrentU...

Is necessary to compile linq queries in subsonic?

I'd like to know if it's necessary to compile linq queries to the subsonic entities? For example would I'd need to compile the following linq query? var comments = from a in All() where a.ParentCommentId == ArticleCommentId select a; ...

Pipes and Filters and CompiledQuery.Compile

Hi guys I have started using linq to sql and the entity framework and have found the development experience to be fairly good. Like the way you can break a query apart and combine different queries is quite nice - see pipes and filters. But the problem that I have found is that performance can be greatly increased (in my case by a fa...

Linq-to-sql Compiled Query returns object NOT belonging to submitted DataContext ?

Compiled query: public static class Machines { public static readonly Func<OperationalDataContext, short, Machine> QueryMachineById = CompiledQuery.Compile((OperationalDataContext db, short machineID) => db.Machines.Where(m => m.MachineID == machineID).SingleOrDefault() ); public s...

LINQ compiled query DataBind issue

Hello All, I have a pretty extensive reporting page that uses LINQ. There is one main function that returns an IQueryable object. I then further filter / aggregate the returned query depending on the report the user needs. I changed this function to a compiled query, it worked great, and the speed increase was astonishing. The only pr...

Filter list as a parameter in a compiled query

I have the following compiled query that I want to return a list of "groups" that don't have a "GroupID" that's contained in a filtered list: CompiledQuery.Compile(ConfigEntities contexty, List<int> list) => from c in context.Groups where (!csList.Contains(c.GroupID)) select c).ToList() However I'm getting the following r...

how to use a delegate to get by name a CompiledQuery

I'm trying to find and run a CompiledQuery given the name. How do I access the compiled query by name and how do I then invoke the delegate? Here's as far as I can get - I get the error 'Error binding to target method' public class ActivityRepository { private readonly ActivityDataContext _db; public ActivityRepository() {...

LINQ-to-SQL "Member access not legal on type" exception with unioned and compiled query

I have multiple queries that I'd like to union together, then compile the entire thing. The uncompiled query runs fine, but an "InvalidOperationException: Member access 'Int32 Id' of 'UserQuery+Foo' not legal on type 'System.Linq.IQueryable`1[UserQuery+Foo]." exception is thrown when the same query is compiled and run. How do I fix thi...

Does applying additional clauses to a compiled query cause a recompile?

If I have a compiled entities query via CompiledQuery.Compile and I then tack on another .Where() clause or .OrderBy() clause, do these addition clauses force a full recompile, a partial recompile, or no recompile? ...

DataContext compiled query problem with .NET 4

My project (UI layer is asp.mvc) was developed using .NET 3.5. After upgrading to .NET 4.0 I have got problem with compiled queries: [ArgumentException: Query was compiled for a different mapping source than the one associated with the specified DataContext.] System.Data.Linq.CompiledQuery.ExecuteQuery(DataContext context, Object[] ...