SharePoint 2007: How can I perform a series of operations within a transaction?

I would really like to know how to perform a series of operations in a SharePoint context in a transaction. For example, I would like to do something like the following:

context.BeginTransaction(); listItemA.Update(); listItemB.Update(); context.CommitTransaction(); 

I know this is not possible with the OOTB API, but someone needs to figure out how to do this. Can I get a link to a database connection to process a transaction? Or any other ideas?

+6
sharepoint transactions transactionscope moss wss
source share
6 answers

Although SharePoint technically uses SQL as storage support, we should not consider it as a database application. SP creates an arbitrary file system with which we interact through the API. Thus, from the point of view of the developer, Sharepoint has virtually no transactions.

Unfortunately, almost everything is in this :) Even thinking about trying to directly link to the database will lead to the pain of the Old Testament. Wearing clothes, crying and gnashing of teeth;)

+8
source share

Just use Recycle (). Watch for the GUID in the GUID []. If you cannot open the RecycleBin utility and restore / delete everything using the GUID

 GUID[] guids = new GUID[]; SPWeb web; SPListItem item; SPList list; try { foreach item in list GUID current = item.Recycle() guids.add(current); item.Delete(); } catch{ if one fails : web.RecycleBin.Restore(guids); } if all succeed : web.RecycleBin.Delete(guids): 
+6
source share

If you use version control, you can try a solution that validates your item, performs updates, and validates. If rollback is required, just cancel the check.

Can work?

+4
source share

Another option is to use the workflow mentioned here . As stated in How Windows SharePoint Services processes process workflows :

Windows SharePoint Services starts the workflow until it reaches the point where it cannot act, because it is waiting for an event to occur: for For example, the user must assign the task as completed. Only then does the โ€œcommit pointโ€ make Windows SharePoint Services commit the changes made to the previous Windows SharePoint Activities related to specific services. These changes are transferred to a single SQL transaction.

+1
source share

No Sharepoint provides a SQL server as a transactional capability.

As Rutger Hemrika said, this is a much better way to do this than any other I've seen so far.

0
source share

Sharepoint does not offer transaction support out of the box. Here is a good resource Creating System.Transactions Resource Manager for SharePoint Although I would save and save any critical data directly in RDB.

0
source share

All Articles