开发者

Return the uniqueidentifier with entity framework

开发者 https://www.devze.com 2022-12-21 23:39 出处:网络
I am using Entity Framework 3.5, while inserting a record i want to return the unique identifier with entity framework.开发者_如何学C How to do that?After calling savechages the new id will be stored

I am using Entity Framework 3.5, while inserting a record i want to return the unique identifier with entity framework.开发者_如何学C How to do that?


After calling savechages the new id will be stored in the entity. so you can retrieve from the entity.


More generally, "To ensure that objects on the client have been updated by data source-side logic, you can call the Refresh method with the StoreWins value after you call SaveChanges.", per MSDN.

http://msdn.microsoft.com/en-us/library/bb738618.aspx


One way that I have taken to working is, when sending a record to my DataLayer/Business Logic Layer, is to have the DL/BLL do the update/insert, then retrieve the record back from the DB and return it with a boolean indicating success or failure.

That way, I can immediately refresh the record in the interface with the written one so I can be sure the record actually went in how it should have.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号