Home Get output 'inserted' on update with Entity Framework
Reply: 0

Get output 'inserted' on update with Entity Framework

user555
1#
user555 Published in July 17, 2018, 7:24 pm

SQL Server provides output for inserted and updated record with the 'inserted' keyword.

I have a table representing a processing queue. I use the following query to lock a record and get the ID of the locked record:

UPDATE TOP (1) GlobalTrans
SET LockDateTime = GETUTCDATE()
OUTPUT inserted.ID
WHERE LockDateTime IS NULL

This will output a column named ID with all the updated record IDs (a single ID in my case). How can I translate this into EF in C# to execute the update and get the ID back?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.319851 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO