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 }
});
}