Home > Enterprise >  How to update multiple rows of data using linq?
How to update multiple rows of data using linq?

Time:10-20

I am new to linq query and EFCore, I am needed to design an API which updates multiple rows of data. This is an example of my current database table in postgresql:

| id   | value |
| ---- | ----- |
| 1    | 123   |
| 2    | 456   |

I want to write an update API using linq query to allow user to update using JSON into:

| id   | value |
| ---- | ----- |
| 1    | abc   |
| 2    | zxc   |

What is the best approach to code this API?

CodePudding user response:

You are not giving enough information about what is your logic here. But it seems you'd like to use this: https://entityframework-extensions.net/bulk-update

CodePudding user response:

My advice is you try to use the out-of-the-box functionality. So do the changes you want to do, and then when you are happy do the SaveChanges() that does everything.

And then ask about specific challenges you experience.

  • Related