SharePoint 2007:如何在事务中执行一系列操作?
我很想知道如何在事务中的 SharePoint 上下文中执行一系列操作。 例如,我希望能够执行如下操作:
context.BeginTransaction();
listItemA.Update();
listItemB.Update();
context.CommitTransaction();
我知道使用 OOTB API 不可能做到这一点,但必须有人弄清楚如何实现这一点。 是否可以获取对数据库连接的引用来处理事务? 或者还有其他想法吗?
I would love to know how to perform a series of operations in a SharePoint context within a transaction. For example, I would like to be able to do something like the following:
context.BeginTransaction();
listItemA.Update();
listItemB.Update();
context.CommitTransaction();
I know this isn't possible with the OOTB APIs, but someone has got to have figured out how to accomplish this. Is it possible to get a reference to the database connection in order to handle the transaction? Or any other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
只需使用 Recycle() 即可。 在 GUID[] 中跟踪 GUID。 如果打开 RecycleBin 失败
并通过 GUID 恢复/删除所有内容
Simply use Recycle(). Keep track of the GUID in a GUID[]. If one fails open de RecycleBin
and restore/delete all by GUID
如果您使用版本控制,您可以尝试签出项目、执行更新并签入的解决方案。如果需要回滚,只需撤消签出即可。
也许可以工作?
If you use versioning you could try a solution that checks out your item, performs updates and checks in. If rollback is needed, just undo the checkout.
Could work maybe??
另一种选择是使用工作流程,此处提到。 如 Windows SharePoint Services 如何处理工作流活动中所述:
Another option is to use workflow, mentioned here. As stated in How Windows SharePoint Services Processes Workflow Activities:
没有Sharepoint 不提供类似SQL 服务器的事务功能。
正如 Rutger Hemrika 所言,这是一种比我迄今为止见过的任何其他方法都要好得多的方法。
No Sharepoint does not provide SQL server like transaction capability.
As Rutger Hemrika posted, thats a far better way of doing it than anyhing else that I have seen until now.
Sharepoint 不提供开箱即用的事务支持。 这是关于 为 SharePoint 构建 System.Transactions 资源管理器 的一个很好的资源,尽管我会保存并将任何关键数据直接存储到 RDB 中。
Sharepoint does not offer transaction support out of the box. Here is a good resource on Building a System.Transactions resource manager for SharePoint Though I would save the effort and store any critical data directly into a RDB.
尽管 SharePoint 在技术上使用 SQL 作为存储支持,但我们不应该将其视为基于数据库的应用程序。 SP 创建了某种虚假文件系统,我们通过 API 与之交互。 因此,从开发人员的角度来看,Sharepoint 几乎不需要交易。
不幸的是,这几乎就是它的全部内容了:) 即使考虑尝试直接参与数据库也会导致旧约痛苦。 撕裂衣服、哀嚎、咬牙切齿;)
Although SharePoint technically uses SQL as a storage backing, we're not supposed to treat it like a database-based application. SP creates a faux-filesystem of sorts, which is what we interact with via the API. So from the developer perspective, Sharepoint is pretty much transaction-less.
Unfortunately that's pretty much all there is to it :) Even thinking about trying to get involved with the database directly will result in Old Testament pain. Rending of garments, wailing and gnashing of teeth ;)