Questions tagged [compiled-query]

CompiledQuery is a .NET helper class for the Entity Framework, which enables compilation of of database queries for better performance.

CompiledQuery is a .NET helper class for the Entity Framework. It enables user code to compile a query to the source (based on a method signature), to be re-used efficiently with different parameter values.

68 questions
23
votes
5 answers

When should I use a CompiledQuery?

I have a table: -- Tag ID | Name ----------- 1 | c# 2 | linq 3 | entity-framework I have a class that will have the following methods: IEnumerable GetAll(); IEnumerable GetByName(); Should I use a compiled query in this…
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
14
votes
3 answers

Do we still need stored procedures when using compiled queries?

When using compiled queries in entity framework (or linq-to-sql) in combination with SQL Server, is there actually still any performance benefit in using stored procedures? Compiled queries will be cached as parameterized queries, so performance…
Carvellis
  • 3,992
  • 2
  • 34
  • 66
13
votes
2 answers

How do compiled queries in slick actually work?

I am looking for a detailed explanation about the execution of compiled queries. I can't understand how they just compile once and the advantage behind their use
Im89
  • 139
  • 1
  • 10
12
votes
1 answer

Entity Framework 6 Compiled LINQ Query

I'm trying to improve performance of a web application by caching a query. public static Func, IQueryable> CompiledDuplicatedResponses = CompiledQuery.Compile,…
Giox
  • 4,785
  • 8
  • 38
  • 81
10
votes
4 answers

LINQ: When to use Compiled Queries?

I'd like some expert advice on this. I've used compiled queries before, but for this particular case, i'm not sure whether it's appropriate. It's a search form where the query changes and is dependent on what is being searched on. static…
mnsr
  • 12,337
  • 4
  • 53
  • 79
10
votes
1 answer

Is all the query in Entity framework 6 is already compiled?

I want to optimized my queries in Entity Framework 6.1.3, so I need to know that whether queries are already CompiledQueries or I need to write them manually as CompiledQuery? Thanks in advance.
Aashish Kumar
  • 1,563
  • 1
  • 15
  • 19
9
votes
1 answer

Compiled Query no implicit reference conversion to ObjectContext

I'm creating a delegate to retrieve all album records in the database. I've used this same way in another project, but for some reason I'm getting an error this time. Have I missed a step? I'm not sure why this error is appearing. Code …
Cody
  • 8,686
  • 18
  • 71
  • 126
8
votes
1 answer

LINQ-to-SQL Compiled Query Problem (works as uncompiled query)

I have C# extension methods on IQueryable, e.g. FindNewCustomers() and FindCustomersRegisteredAfter(int year) and so forth which I use to "chain" a query together for LINQ to SQL. Now to my problem: I want to create compiled queries, e.g.: private…
Alex
  • 75,813
  • 86
  • 255
  • 348
7
votes
3 answers

get generated sql from a compiled linq query

Is it possible to get the generated SQL from a compiled linq query?
dcarneiro
  • 7,060
  • 11
  • 51
  • 74
7
votes
5 answers

How many times does a compiled query have to recompile during the lifecycle of an application?

In a website, if I have a class: public class Provider { static readonly Func> AllTags = CompiledQuery.Compile> ( e => e.Tags ); public…
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
6
votes
2 answers

including "offline" code in compiled querys

What happens behind the curtains when I include a function into my compiled query, like I do with DataConvert.ToThema() here to convert a table object into my custom business object: public static class Queries { public static…
magnattic
  • 12,638
  • 13
  • 62
  • 115
6
votes
4 answers

Compiled LINQ query & DataLoadOptions... with a twist!

I know about the method discussed here: Solving common problems with Compiled Queries in Linq to Sql for high demand ASP.NET websites ... but this doesn't work for my situation as i get a : "Setting load options is not allowed after results have…
krisg
  • 796
  • 1
  • 9
  • 24
5
votes
1 answer

CompiledQuery throws ArgumentException

I'm trying to use a very simple pre-compiled query within an extension method to retrieve data using LINQ to SQL. SytelineRepository is my custom DataContext that uses external mapping files, and I'm querying the JobOrders table. I've been using…
Eric H
  • 597
  • 5
  • 19
4
votes
1 answer

How to fix "System.InvalidOperationException: Invalid attempt to call Read when reader is closed" when invoking the Compiled Query

When calling ToList() after invoking the compiled query I sometimes(!) receive an exception - System.InvalidOperationException: Invalid attempt to call Read when reader is closed. The DB context is created for every "invoke" calling, the queries are…
mmam
  • 86
  • 6
4
votes
1 answer

Switch statement in compiled query possible?

Is it at all possible to use something like a switch statement in a compiled query for linq to entities/sql? For example when returning sorted records from the database, I would like to use a switch-like statement within one compiled query to sort…
Carvellis
  • 3,992
  • 2
  • 34
  • 66
1
2 3 4 5