开发者

LINQ to SQL - Is there a way to limit the Scope of SubmitChanges()?

Is there a way to limit the scope of SubmitChanges() to a subset of the overall data domain?

Example:

Bob intends to update a Web Order, but Alice inserted a property, unbeknownst to Bob, that updates a product price (in memory only, not pushed to DB) upon being written to. Bob considers this a travesty that should be avoided at all costs. Bob wishes he could have constrained the scope of the update to the WebOrders sub-domain.

Based upon my understanding, I have to trust that unwanted changes have 开发者_高级运维not been made to other parts of the domain by other code in the application.

It would seem nice to be able to constrain the SubmitChanges() to only touch those objects from within a subset of the domain.


No it is not possible. DataContext is unit of work (it behaves exactly same as context in entity framework) so first of all it should not be shared between multiple user operations. Only Bob's changes should be in the context and because of that he either decides to save all changes or throw away the context (= Dispose) with all changes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜