开发者

Return the uniqueidentifier with entity framework

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜