Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to run parallel queries in sql server with entity framework

async Task<List<E1Entity>> GetE1Data()
{
    using(var MyCtx = new MyCtx())
    {
         return await MyCtx.E1.Where(bla bla bla).ToListAsync();
    }
}

async Task<List<E2Entity>> GetE2Data()
{
    using(var MyCtx = new MyCtx())
    {
         return await MyCtx.E2.Where(bla bla bla).ToListAsync();
    }
}

async Task DoSomething()
{
    var t1 = GetE1Data();
    var t2 = GetE2Data();
    await Task.WhenAll(t1,t2);
    DoSomething(t1.Result, t2.Result);
}
Comment

how to run parallel queries in sql server with entity framework

EF doesn't support processing multiple requests through the same DbContext object.
If your second asynchronous request on the same DbContext instance starts before the first request finishes (and that's the whole point),
you'll get an error message that your request is processing against an open DataReader.
Comment

PREVIOUS NEXT
Code Example
Sql :: row_number equivalent MS Access for sequential id By Group (2) 
Sql :: sql select query 
Sql :: how to innjert in other database 
Sql :: concatenate sqlites 3 
Sql :: mysql create database if not exists 
Sql :: error-expression-select-list-not-group-by-nonaggregated-column/ 
Sql :: PSQL qith variables 
Sql :: mysql and 
Sql :: oracle params value 
Sql :: sql delete all except 
Sql :: downgrading sql localdb visual studio 
Sql :: how to remove quotes from a string in ssis load file 
Sql :: SQL AS With Expression 
Sql :: except in sql alchemy 
Sql :: error infor in sql server 
Sql :: python sql passer des parametres dans une requet pymysql 
Sql :: mysql – Error ‘Column count of mysql.user is wrong. Expected 45, found 43. The table is probably corrupted’ on query. 
Sql :: sql dcl queries 
Sql :: A bad way of running a SQL query in JDBC 
Sql :: decalre table in sql 
Sql :: ring MySQL get the inserted row id 
Sql :: PGSQL dynamic table name 
Sql :: many to many getting data mysql 
Sql :: mysql load data infile default file location 
Sql :: Update Query in SQL Server Table - NAYCode.com 
Sql :: subquery postgresql syntax 
Sql :: BSD sed: extra characters at the end of d command 
Sql :: add column in sql server ubuntu 
Sql :: http_user agent vers SQL 
Sql :: trigger vérifier stock 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =