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

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

Compiled query: public static class Machines { public static readonly Func QueryMachineById = CompiledQuery.Compile((OperationalDataContext db, short machineID) => …
4
votes
2 answers

Does Sql Server 2014's "Hekaton" compiled stored procedures address parameter sniffing issues?

SQL Server 2014's "Hekaton" in-memory table optimization proclaims, "Native compilation of business logic in stored procedures." Because of issues with "parameter sniffing" (see here and here) in SQL Server 2012 and earlier, however, I have always…
3
votes
2 answers

Delete a record entity framework

I am receiving an exception: Unable to update the EntitySet 'Session' because it has a DefiningQuery and no element exists in the element to support the current operation. while trying to delete a row from a database table. The exception…
3
votes
0 answers

Linq2Sql "Member access not legal on type" exception

I have a static class with compiled queries and I want to reuse some of subqueries. So i extract a common part into a static property and then reference it in multiple queries: public static class Query { // common part static…
UserControl
  • 14,766
  • 20
  • 100
  • 187
3
votes
2 answers

Which methods to close a compiled query

As we know you can't add an extra clause like .Where() or .First() to a compiled query, because that changes the query and forces a recompile. What I would like to know is which methods can be used to "close" a compiled query. I know most people…
Carvellis
  • 3,992
  • 2
  • 34
  • 66
3
votes
4 answers

Why doesn't this CompiledQuery give a performance improvement?

I am trying to speed up an often used query. Using a CompiledQuery seemed to be the answer. But when I tried the compiled version, there was no difference in performance between the compiled and non-compiled versions. Can someone please tell me why…
Grammarian
  • 6,774
  • 1
  • 18
  • 32
3
votes
1 answer

Compiled query returns the same thing every time

I have this compiled query: private static Func FooQuery = CompiledQuery.Compile( _db => _db.FooTable.SingleOrDefault(f => f.DeletionDate == null || f.DeletionDate > DateTime.UtcNow) ); When I run it once, it…
Emmett
  • 14,035
  • 12
  • 56
  • 81
3
votes
1 answer

Entity framework make compiled query generic

I use entity framework and Im trying to make such a query generic, so it can be used for any entity type (with an assumption that each entity has property int Id). I tried something like this, but there is no collection ctx.TEntity or something…
John Smith
  • 1,783
  • 6
  • 22
  • 36
3
votes
1 answer

Returning KeyValuePair from a Linq Compiled Query

I'm just getting to grips with Compiled Queries in Linq, and have come across some strange behaviour. This query compiles fine: public static Func GetJourneyByUrl = CompiledQuery.Compile
royse41
  • 2,310
  • 4
  • 22
  • 29
2
votes
1 answer

using union on linq compiled queries

I'm trying to find the best way to use union with linq. currently I have to compiled queries with the same signature: public Func> Query1 public Func> Query2 and on my repository…
dcarneiro
  • 7,060
  • 11
  • 51
  • 74
2
votes
0 answers

Compiled query replacement for .Net 4.0 and EF6

I have an Asp.Net MVC application built with .Net 4.0 and EF6. To improve performance of the application, I came across various posts and got to know that we must have compiled queries to drastically increase the performance of the application. So I…
Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200
2
votes
2 answers

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…
MikeWyatt
  • 7,842
  • 10
  • 50
  • 71
2
votes
1 answer

Entity Framework 4 simple Compiled Query internal exception on compilation

I want to retrieve one page from a sorted table. I want the sorting and paging to be done on the server. For this I created the following compiled query: internal static readonly Func>…
Carvellis
  • 3,992
  • 2
  • 34
  • 66
2
votes
4 answers

laravel Eloquent ORM - How to get compiled query?

In Laravel 4.2 I want to get Compiled Query. This is what i have: $product = Product::where('id', '=', '100')->get(); I want compiled query like: select * from products where id = 100 Purpose of the question is: i want to use it as sub query in…
akash varlani
  • 320
  • 1
  • 4
  • 16
2
votes
2 answers

Linq To Sql: Compiled Queries and Extension Methods

I'm interessted, how does Linq2Sql handles a compiled query, that returns IQueryable. If I call an extension method based on a compiled query like "GetEntitiesCompiled().Count()" or "GetEntitiesCompiled().Take(x)". What does Linq2Sql do in the…
Beni