开发者

Linq to Enities: Result set not getting updated after Stored Procedure Call

In LINQ to Entities, I map the result set of a stored procedure to an entity.

Within the stored procedure, I execute some update statements and return the result set by running a SELECT query and mapping that result set to the entity.

The database rows get updated correctly, but the entities returned are not reflecting the changes. Instead, the data before the update is getting returned?

Any s开发者_StackOverflow社区uggestions?

Thank you. Abe


Actually, it turns out the DataContext.Refresh method solved my problem at http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.refresh.aspx

Here's my code:

db.Refresh(System.Data.Objects.RefreshMode.StoreWins, affectedProjectTasks);

Thanks Marc for pointing me to the right direction! Abe


Are the entities in question already cached in the context? (i.e. have you queried them already?)

If so, the identity manager will always give you back the original object (rather than creating a new object with the same identity in the same context). Hence for data that has already been read (by other queries) only the identity/primary-key field(s) are considered.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜