开发者

Entity Framework : interrupt running SaveChanges

I have a unique ObjectContext, on which I perform a SaveChanges(). This operation takes some time (~60 seconds). This operation is executed in a thread.

My user have a "Cancel" button on the screen.

I'm able to stop the thread, but if the SaveChanges() has already started I can't find anyway to cancel it.

In fact I found no way to access the underlying transaction (I also have an Isolation level issue : this operation locks almost all tables in database, so the application cannot be used by other users).

Would it work if I closed the underlying connection ? The EF won't be able to send a Rollback instruction but I guess the database would perform it anyway, no ?

I've seen that I could use TransactionScope but it needs to access DTC and my host 开发者_Go百科is not really performant when it comes to edit server/network configuration.

So if a "Entity Framework" solution exist I'd prefer that one.


is your SaveChanges() saving multiple updates? Is it possible to update then save each individually?

Then, if you are inside a transaction, and user cancels, you'd have more granularity in your saves.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜