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
2
votes
1 answer

Why can't you return a List from a Compiled Query?

I was speeding up my app by using compiled queries for queries which were getting hit over and over. I tried to implement it like this: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() …
Andrew
  • 11,068
  • 17
  • 52
  • 62
2
votes
1 answer

Get Total Records Count and Custom No of Records in One Database Hit

I am trying to implement custom paging in Ext.js grid, I need to get the total records for my table and the records according to page size. I am using a compiled query for this. But I want to give just one database hit. List
2
votes
2 answers

How to extract the Sql Command from a Compiled Linq Query

In normal (not compiled) Linq to Sql queries you can extract the SQLCommand from the IQueryable via the following code: SqlCommand cmd = (SqlCommand)table.Context.GetCommand(query); Is it possible to do the same for a compiled query? The following…
Andrew Harry
  • 13,773
  • 18
  • 67
  • 102
2
votes
0 answers

Use Inline Table Valued Function in LINQ Compiled Query

Is it possible to create a LINQ compiled query that utilizes an ITVF (inline table valued function)?
Alex
  • 75,813
  • 86
  • 255
  • 348
1
vote
1 answer

linq compiled query, class field

How can I insted of public var compiledQuery write Func < MYEntities,string, ???> public var compiledQuery = CompiledQuery.Compile((AddresEntities ctx, string name) => from x in ctx.User where x.Name.Contains(name) select new {…
jasin_89
  • 1,993
  • 7
  • 30
  • 41
1
vote
0 answers

What are the best practices for determining when (or not) to pre-compile a Linq Query?

I am currently refactoring a silverlight application and pulling out frequently used queries to a utility class. There are a lot of queries in the application, and while there were some obvious targets, when I get down to very small queries like…
Noel
  • 600
  • 16
  • 37
1
vote
2 answers

LINQ compiled query won't execute - ArgumentNulException was unhandled

I'm testing the Compiled Queries for the first time. My current query is: Shared compiledLatestDate As Func(Of RackJobbingDataDataContext, ArtikelInfoParameters, List(Of VerdelingPlanning)) = _ CompiledQuery.Compile(Of…
NicoJuicy
  • 3,435
  • 4
  • 40
  • 66
1
vote
2 answers

LINQ compiled query select sum multiple columns

I have a table: ForObjectTypeID (short, PK) ForObjectID (int, PK) UserID (int, PK) Upvote (bool) ShadowBannedVote (bool) Given an ObjectTypeID and ObjectID, I wish to return a Tuple where the respective values are: Total Votes:…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
1
vote
1 answer

How do I refactor compiled LINQ queries?

Is it possible to refactor compiled LINQ to SQL queries? Suppose that I have a query with some logic, and I'd like to build onto it. Is it possible to reuse that query? For example, suppose I have a basic query to get active items: Func
Hosam Aly
  • 41,555
  • 36
  • 141
  • 182
1
vote
1 answer

GenericDataRepository with Compiled Queries

I have a MVC project with many layers(View,Model,DataAccess,Business) and I am using GenericDataRepository in my DataAccessLayer. I would like to enhance the GenericDataRepository's performance with CompiledQueries. here is my GenericDataRepository…
Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189
1
vote
1 answer

How can I "warm up" a LinqToSql precompiled query?

In LinqToSql, precompiled queries are great - but it still requires me to take the compilation performance hit the first time the query is used. I would like to 'warm up' these precompiled queries in the background when the application starts up. …
Shaun Rowan
  • 9,269
  • 4
  • 28
  • 52
1
vote
0 answers

Map model object to DataConext

Below is the code I'm trying to use for my first attempt at a compiled linq query. The code builds fine and the site will run as it's expected to, however once the program calls the compiled method I recieve the error: The type…
NealR
  • 10,189
  • 61
  • 159
  • 299
1
vote
1 answer

How to make compiled cached queries outlive the context?

Since Entity Framework 5 queries are compiled and cached by default. This boosts performance for repeated queries. However context is designed to be a shortlived object and is disposed after processing the request. Therefore we have many repeated…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
1
vote
2 answers

Linq Compiled Queries and int[] as parameter

I'm using the following LINQ to SQL compiled query. private static Func MainSearchQuery = CompiledQuery.Compile((MyDataContext db, int[] online ) => (from u in db.Users where…
dan
  • 11
  • 1
  • 3
1
vote
0 answers

Using a CompiledQuery breaks my query that uses an IQueryable property of my datacontext

I have a property on a data context that I use in queries: public IQueryable NonCompleteCallouts { get { return SCCalls.Where(call => call.SCCalT.CalT_Est_Work.HasValue && …
George Duckett
  • 31,770
  • 9
  • 95
  • 162