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 Query
- EF 6 Plus - How To Do Future Raw Query
- How to construct a raw SQL Query in EF Core with dynamic number of parameters
- 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#
- How to query by where clause with EF code first
- How to get SQL query into LINQ form in C# code
- How can I code a Linq query to do an upward Include?
- How can we express the following code using query expression?
- How to break complex query into different methods to achieve less code complexity
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How to integrate external list to raw sql query join as table in a linq raw sql query
- How to Query Icollections of Entity Framework Code First Data
- How do I determine the source of unpredictable LINQ query results?
- How to Select top (5) contributors group by Business type code in c# linq query
- How can I code numerous MIN functions into one LINQ to DataSet query
- How to code this LINQ query in a better way
- How to write aggregate query in LINQ reusing part of the select code
- How to execute code as a part of the LINQ query
- how to write a Linq query with a EF code first Many to Many relationship
- How to LINQ Query Code First generated EF6 hierarchical entities (entities within entities)?
- How to execute raw SQL Query in my Dot net core project? Or how to translate it to Linq?
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- How to assign LINQ Query to a variable and then use it later in the code
- LINQ query on dotnet code and how concat will work here
- How to use one Column of Sql query into another sql query inside C# Code
- How to use Future query Nhibernate in case of many to many association
- How to make filtration query fast in my C# code with MySQL?
- How Filter Binding Source Connected To linq Query
- How would you do a "not in" query with LINQ?
More Query from same tag
- automate process of record being inserted into database table using asp.net
- How to sort a collection based on type in LINQ
- LINQ - Should I somehow SubmitChanges() periodically if I have a lot of changes?
- Set rank based on Value in List
- XML LINQ query returns nothing
- Linq: Except on two different types of dictionaries
- Convert this SQL query to LINQ using .GroupBy() methods
- Performance tuning Entity Framework queries
- Search Large ConcurrentBag?
- Project Euler #4 with C#
- Joins in Linq 2 SQL using IDataContext
- Unable to access instance variable with an Extension Method with Lambda
- Generate Dynamic LINQ Expression By Iterating object properties
- Data in Linq query not in join is not in output to json only those that are related in 2 classes are showing up
- default(T?) does not return null when T is a value type
- Select records count from multiple tables in a single query
- Linq Max with Default Value
- How can I convert a lambda-expression between different (but compatible) models?
- C# lock with LINQ query
- Linq query to join 2 lists of objects and get the altered values as list
- dictonary requeiers a model item of type system.collections.generic.ienumeruble
- Get the max date from a list of value inside a dictionary
- ASP.NET MVC3 (C#) Image from URL to database
- Multiple SUM using LINQ
- List ordered in a particular way
- Creating LINQ with where clause
- Linq Query If Field Is In An Array?
- Getting MethodInfo without name as string
- LINQ refactoring help needed
- wrap a linq expression with another linq expression