Parallel EntityFramework

Posted by mehanik on Stack Overflow See other posts from Stack Overflow or by mehanik
Published on 2010-04-28T11:13:29Z Indexed on 2010/04/28 11:23 UTC
Read the original article Hit count: 376

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about parallel

Related posts about entity-framework