I have tried in several ways a linq query to retrieve the last row inserted in a sql server table.
I need somenthing like this
var lastId = from u in context.sistema_Documentos where u.id == max select u;
Some people says it is not possible, some says It is not safe or affect performance drastically .. How could I perform this query?
Ps.. would be this a good approach?
var lastId = from u in context.sistema_Documentos orderby u.id descending select u.id;
The identity value, that you are looking for, is available after you did the
SubmitChanges()method. You can read it like so: