I have a console application based on .net standard. This console application sends a list to a Web API.
For example, my class is something like;
public class Person
{
public Guid Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
The Web API accepts 1000 records in a single request. The process binds List variable and sends the web API. Web Api response is something like
public class PersonResponse
{
public Guid PersonId { get; set; }
public Guid ApiId{ get; set; }
}
Now, I need to update my SQL Server table and I create an update statement like
string query = "UPDATE Person SET ApiId = @apiId WHERE Id = @personId";
My main issue is, I have to execute this update statement for 1000 times. I open one SQL connection and start to update that 1000 record one by one. I don't like the way how I did this. What is the best way to update these 1000 records?