score:2
Future
and all methods like DeferredFirst
are extension methods on IQueryable<T>
:
public static QueryFutureEnumerable<T> Future<T>(this IQueryable<T> query)
Database.SqlQuery
returns DbRawSqlQuery<T>
, which implements IEnumerable<T>
, not IQueryable<T>
, so the extension doesn't apply. There's no way to execute SqlQuery
s in one Future
batch with other queries.
You can alleviate some of the "pain" by opening the context's connection before executing a mix of queries and closing it afterwards. That prevents EF from closing and opening the connection for each individual query it executes. It's not the same as executing queries in deferrable batches, but it may add some efficiency.
try
{
context.Database.Connection.Open();
...
}
finally
{
context.Database.Connection.Close();
}
Source: stackoverflow.com
Related Articles
- EF 6 Plus - How To Do Future Raw Query
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- LINQ Source Code Available
- prevent unnecessary cross joins in count query of generated sql code
- .NET 4 Code Contracts: "requires unproven: source != null"
- EF Code First comparing null values generates strange query
- linq - how do you do a query for items in one query source that are not in another one?
- How can I write the following code more elegantly using LINQ query syntax?
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- Avoid extra loop and could not find implementation of query pattern for source type int Select not found
- C# Linq query help removing foreach loops creating cleaner code
- Use a linq query as microsoft local report Data Source (WinForms)
- Can I use a compiled query as a source in a second query?
- Determine the source DataContext for a Linq to Sql query
- Query expressions over source type 'dynamic' or with a join sequence of type 'dynamic' are not allowed
- LINQ query returns old results when source list is re-initialized
- How to query by where clause with EF code first
- How to get SQL query into LINQ form in C# code
- Code Example for Add DateTime and TimeSpan in EF query
- Could not find an implementation of the query pattern for source type
- How can I code a Linq query to do an upward Include?
- creating Linq to sqlite dbml from DbLinq source code
- What would be a reasonably fast way to code this sql query in c#?
- Identify source of linq to sql query
- NHibernate LINQ query performance, which code fragment is better?
- Linq sub query when using a repository pattern with EF code first
- Using LINQ query result for data source for GridControl c#
- How can we express the following code using query expression?
- Take a sequence of elements from an array from i to j using C# and extension method
- Find / Count Redundant Records in a List<T>
- How to write fast subquery in where condition in linq
- How to determine if an IEnumerable has been evaluated?
- How to select a field with linq on datarow
- Linq query to find items that could be within a range
- Serialize Linq Results directly to JSON
- LINQ aggregating multiple IEnumerables into one?
- Exposing a protected collection for LINQ queries
- Alternate rows coloring in Excel using Epplus
- How do I filter db.table by another another column from another table in MVC 5?
- Getting unmatched array from two array objects
- 'Linq to Entities does not recognize the method' when ordering by Object
- ling sql group with join
- Input Text File and Read First Character of Each Line + Count Occurences
- Fail to convert LINQ query result to ToList
- can't get the right output from a "group by"
- Cant use OrderBy with int[,] - c#
- How to call a method in Linq query?
- Linq To Entities - how to filter on child entities