Bulk update in entity framework in web api
I am working on a web api project, where client application will send bulk records to api to update into db. I am using C# and Entity framework.
Client application will send list of records
[
'DAD88F3D-518E-47CC-A5D9-33E15D8373A7',
'B3960124-34CF-445C-A1A7-3F1ABB383C01',
'6883E1BE-218E-499E-AC6D-13E9E7D099A9',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'4950C8EC-A6CC-42B7-AD2A-E029E7FCF11A',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'4938EB64-C795-46B9-B42D-D48F32AD8DF4'
]
This list would have approx 100 records at a time.
So API has to update multiple db tables with all matching Ids in the list and returns status back to client for each Ids that which Update operation is success and which is failed. Client application has to do some operation based on success or failed status.
Update tableName set Deleted = 'Y' where id in (above list )
Update anotherTableName set enrollment='Incomplete' where id in (above list)
So how it can be done in entity framework for more records update.
entity-framework bulkupdate
add a comment |
I am working on a web api project, where client application will send bulk records to api to update into db. I am using C# and Entity framework.
Client application will send list of records
[
'DAD88F3D-518E-47CC-A5D9-33E15D8373A7',
'B3960124-34CF-445C-A1A7-3F1ABB383C01',
'6883E1BE-218E-499E-AC6D-13E9E7D099A9',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'4950C8EC-A6CC-42B7-AD2A-E029E7FCF11A',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'4938EB64-C795-46B9-B42D-D48F32AD8DF4'
]
This list would have approx 100 records at a time.
So API has to update multiple db tables with all matching Ids in the list and returns status back to client for each Ids that which Update operation is success and which is failed. Client application has to do some operation based on success or failed status.
Update tableName set Deleted = 'Y' where id in (above list )
Update anotherTableName set enrollment='Incomplete' where id in (above list)
So how it can be done in entity framework for more records update.
entity-framework bulkupdate
add a comment |
I am working on a web api project, where client application will send bulk records to api to update into db. I am using C# and Entity framework.
Client application will send list of records
[
'DAD88F3D-518E-47CC-A5D9-33E15D8373A7',
'B3960124-34CF-445C-A1A7-3F1ABB383C01',
'6883E1BE-218E-499E-AC6D-13E9E7D099A9',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'4950C8EC-A6CC-42B7-AD2A-E029E7FCF11A',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'4938EB64-C795-46B9-B42D-D48F32AD8DF4'
]
This list would have approx 100 records at a time.
So API has to update multiple db tables with all matching Ids in the list and returns status back to client for each Ids that which Update operation is success and which is failed. Client application has to do some operation based on success or failed status.
Update tableName set Deleted = 'Y' where id in (above list )
Update anotherTableName set enrollment='Incomplete' where id in (above list)
So how it can be done in entity framework for more records update.
entity-framework bulkupdate
I am working on a web api project, where client application will send bulk records to api to update into db. I am using C# and Entity framework.
Client application will send list of records
[
'DAD88F3D-518E-47CC-A5D9-33E15D8373A7',
'B3960124-34CF-445C-A1A7-3F1ABB383C01',
'6883E1BE-218E-499E-AC6D-13E9E7D099A9',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'A2B6D337-A615-4269-9C0F-D24D2479012B',
'4950C8EC-A6CC-42B7-AD2A-E029E7FCF11A',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'C1C477BD-B1DF-45D6-85C4-A381DC596524',
'4938EB64-C795-46B9-B42D-D48F32AD8DF4'
]
This list would have approx 100 records at a time.
So API has to update multiple db tables with all matching Ids in the list and returns status back to client for each Ids that which Update operation is success and which is failed. Client application has to do some operation based on success or failed status.
Update tableName set Deleted = 'Y' where id in (above list )
Update anotherTableName set enrollment='Incomplete' where id in (above list)
So how it can be done in entity framework for more records update.
entity-framework bulkupdate
entity-framework bulkupdate
asked Nov 15 '18 at 15:29
VishwakantVishwakant
466
466
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Disclaimer: I'm the owner of the project Entity Framework Plus
If you are looking to update multiple rows to the same value, this free library will do the job.
context.YourDbSet.Where(x => listIds.Contains(x => x.Id))
.Update(x => x.Deleted = 'Y');
Disclaimer: I'm the owner of the project Entity Framework Extensions
(This library is not free)
If you need to perform BulkUpdate in a list, you can use this library
Example
// Easiest way
context.BulkSaveChanges(); // as your normally do with SaveChanges
// Fastest way
context.BulkUpdate(list);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322731%2fbulk-update-in-entity-framework-in-web-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Disclaimer: I'm the owner of the project Entity Framework Plus
If you are looking to update multiple rows to the same value, this free library will do the job.
context.YourDbSet.Where(x => listIds.Contains(x => x.Id))
.Update(x => x.Deleted = 'Y');
Disclaimer: I'm the owner of the project Entity Framework Extensions
(This library is not free)
If you need to perform BulkUpdate in a list, you can use this library
Example
// Easiest way
context.BulkSaveChanges(); // as your normally do with SaveChanges
// Fastest way
context.BulkUpdate(list);
add a comment |
Disclaimer: I'm the owner of the project Entity Framework Plus
If you are looking to update multiple rows to the same value, this free library will do the job.
context.YourDbSet.Where(x => listIds.Contains(x => x.Id))
.Update(x => x.Deleted = 'Y');
Disclaimer: I'm the owner of the project Entity Framework Extensions
(This library is not free)
If you need to perform BulkUpdate in a list, you can use this library
Example
// Easiest way
context.BulkSaveChanges(); // as your normally do with SaveChanges
// Fastest way
context.BulkUpdate(list);
add a comment |
Disclaimer: I'm the owner of the project Entity Framework Plus
If you are looking to update multiple rows to the same value, this free library will do the job.
context.YourDbSet.Where(x => listIds.Contains(x => x.Id))
.Update(x => x.Deleted = 'Y');
Disclaimer: I'm the owner of the project Entity Framework Extensions
(This library is not free)
If you need to perform BulkUpdate in a list, you can use this library
Example
// Easiest way
context.BulkSaveChanges(); // as your normally do with SaveChanges
// Fastest way
context.BulkUpdate(list);
Disclaimer: I'm the owner of the project Entity Framework Plus
If you are looking to update multiple rows to the same value, this free library will do the job.
context.YourDbSet.Where(x => listIds.Contains(x => x.Id))
.Update(x => x.Deleted = 'Y');
Disclaimer: I'm the owner of the project Entity Framework Extensions
(This library is not free)
If you need to perform BulkUpdate in a list, you can use this library
Example
// Easiest way
context.BulkSaveChanges(); // as your normally do with SaveChanges
// Fastest way
context.BulkUpdate(list);
answered Nov 16 '18 at 14:20
Jonathan MagnanJonathan Magnan
5,95621334
5,95621334
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322731%2fbulk-update-in-entity-framework-in-web-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown