We are now in a situation on a project that we need manipulate multiple user entities at once. By example we will disable 50 users at once. Normally we did that in a gateway
Gateway
OR
But that is not the best practice solution.
The first option overrule the possibility to validate the data. The second is not good performing, because we need iterate the entity for all users
What do you suggest? We want a fast solution, but also a save solution
Hope someone know the right solution. Thanks!
When we use the
You need an Object Realational Mapper (ORM) that has the feature to load those multiple users that match the loop at once so the load is reduced.
Similar for the save operation at the end. All changed entities should be stored at once with a unit of work.
Check the product documentation of the ORM you're using or contact it's vendor to find out which features it offers to support your development.
I would suggest the first option. Updating them all at once in a single query. But you don't state what kind of data validation you would like to do. Maybe you could start a database transaction and issue a second query to validate the result of your 'user disable query' before committing?