Self Servicing Entities with Parallel Foreach

Posts   
 
    
Posts: 10
Joined: 12-Dec-2016
# Posted on: 16-Jan-2017 16:31:17   

The project I am working with references

SD.LLBLGEN.Pro.DQE.SqlServer.NET20 SD.LLBLGEN.Pro.LinqSupportClasses.NET35 SD.LLBLGEN.ProOrmSupportClasses.NET20 SD.LLBLGENPro.QuerySpec

Is there any problem using the self servicing entities in a parallel foreach loop?

Does the self servicing, open and close a connection for each entity? If it opens and closes its own connection per entity, it should be safe yes?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 16-Jan-2017 22:40:42   

What exactly do you do in these loops?

Posts: 10
Joined: 12-Dec-2016
# Posted on: 17-Jan-2017 00:57:55   

Walaa wrote:

What exactly do you do in these loops?

I have a user import process. Customers send their data file, and I need to update the users. Example below.



foreach(var user in datafile)
{
   var entity = UserRepo.GetByEmail(user.Email);
   entity.Firstname = user.Firstname;
   entity.Lastname = user.Lastname;
   entity.EmployeeId = user.EmployeeId;
   entity.Save();
}


Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 17-Jan-2017 10:41:48   

that should be fine indeed.

Frans Bouma | Lead developer LLBLGen Pro