Closed Anshem closed 7 years ago
Helo @Anshem,
It's possible,
But in order to answer this question, I must know how you determine if you need to update the name or the pass, or both?
Best Regards,
Jonathan
For each entity within the dataset, we do know what fieldnames to update (string array within the entity), and we have the proper values in a second string array. After that, for each entity we are able to compound the UPDATE query to only change the values that we need to change (UPDATE [tablename] (---concat first array---) VALUES (---concat second array---)).
Thanks.
Oh I see,
We support some kind of formula, but I believe in your situation, this will be a bad idea (way to much complex for this situation).
I recommend you instead to make the logic in your code and perform multiple Bulk Operations
var groups = dt.AsEnumerable().GroupBy(x => x["ColumnWithFields"].ToString());
foreach (var group in groups)
{
List<DataRow> rows = group.Select(x => x).ToList();
// Bulk Operations
// ... Add the code needed to perform the bulk operations...
}
This way, it will be way more simpler and readable.
Let me know if that could answer to your question or you are looking for a better solution.
Best Regards,
Jonathan
Hello @Anshem ,
Was you satisfied with the answer? Can we close this issue?
Best Regards,
Jonathan
Yes, thank you.
Closing Comment: Answer confirmed
Hi, I have a question about bulk update.
Very simple example. I have this Table:
| ID | NAME | PASS | | 1 | UserA | PassA | | 2 | UserB | PassB |
I want to update for user A his name, and for user B the Pass. How can i do it with bulk?
If I set empty the Pass value for User A, bulk set it like null, and the same for user B with his name. This is a problem for me. How can i resolve it?
What I want to say is that I want to set into bulk only the values that I want to update. This is because of restrictions of my application.
Thanks in advance.