Parallel EntityFramework

c#, entity-framework, parallel-processing

Solution

No, the query is run on the database, not in the client. The database may do the query using multiple threads to accelerate the process, but in any case you can't combine server-side processing with client-side Parallel Extensions.

Problem

Is it possible to make some work in parallel with entity framework for following example? ``` using (var dbContext = new DB()) { var res = (from c in dbContext.Customers orderby c.Name select new { c.Id, c.Name, c.Role } ).ToDictionary(c => c.Id, c => new Dictionary<string, object> { { "Name",c.Name }, { "Role", c.Role } }); } ``` For exampe what will be changed if I add AsParrallel? ``` using (var dbContext = new DB()) { var res = (from c in dbContext.Customers orderby c.Name select new { c.Id, c.Name, c.Role } ).AsParallel().ToDictionary(c => c.Id, c => new Dictionary<string, object> { { "Name",c.Name }, { "Role", c.Role } }); } ``` And one more example. The question is same what are the differences in 3 examples. ``` using (var dbContext = new DB()) { var res = (from c in dbContext.Customers.AsParallel() orderby c.Name select new { c.Id, c.Name, c.Role } ).AsParallel().ToDictionary(c => c.Id, c => new Dictionary<string, object> { { "Name",c.Name }, { "Role", c.Role } }); } ```

Original source