Last active
March 23, 2022 09:29
-
-
Save johnknoop/4c07e80625de8f92746053e23e1ced9d to your computer and use it in GitHub Desktop.
Upsert all in one db roundtrip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IActionResult> Upsert(BulkUpsertRequest request) | |
{ | |
request.Devices.ForEach(d => | |
{ | |
var device = new Device(d.Id, d.Name, d.Metadata.Select(...)); | |
_dbContext.Entry(device).IsModified = true; | |
}) | |
await _dbContext.SaveAsync(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment