Microsoft
Software
Hardware
Network
Question : Get identity of last insert (ASP.NET MVC Entity framework)
I am using ASP.NET MVC 2.0 with entity framework using MySQL as the database.
When I insert a new row into a table, is there a way to get the identity of the row just inserted?
In my repository, I have some code to insert a new row:
public void InsertNotice(Notice notice)
{
db.AddToNotices(notice);
}
At some point later, I save the changes with db.SaveChanges(), but I can't see how to get any information about the inserted row.
I hope that makes sense.
Answer : Get identity of last insert (ASP.NET MVC Entity framework)
I found the solution myself:
public int InsertNotice(Notice notice)
{
db.AddToNotices(notice);
db.SaveChanges();
return notice.NoticeID;
}
Thanks anyway.
Random Solutions
How do you reset the NVRAM via open firmware?
DELETE from a SAS table based on two column values of another table
Storing a Datatble in WPF app for future use.
Jquery ui modal and using form in the pop up window.
Is it worth making iPhone games?
exchange homepage, IIS6, OWA
Mix HTML and VB.NET
problems in the synchronization between a PDA and the Exchange server produced by a Email and Web Security Appliance (3100) v5.0 of mcafee
A SCRIPT THAT WILL SEARCH AND SHOW RESULT FOUND
Remove "Document] is reserved by [author] - Enter password to modify, or open read only" dialog in Word 2007