Transaction in sharepoint RRS feed

  • Question

  • I am using Linq and sharepoint functionality to update data in two list like this-


     using (TransactionScope ts = new TransactionScope())
                        //Using LINQ
                        MyTestSiteEntityDataContext DCtxTest = new MyTestSiteEntityDataContext("http://sharepointsrv:717/mytest/MyTestSite");
                        MainEmpListItem resultMainEmpData = new MainEmpListItem();
                        resultMainEmpData.Empname = (intcount + 1).ToString();


                   //Generating runtime error   (if error comes then i want rollback changes in MainEmpList)
                        int a = 1;
                        int b = 0;
                        a = a / b;

                        //Using Sharepoint classes
                        SPWeb LeaveWeb = SPContext.Current.Web;
                        SPList list = LeaveWeb.Lists["MainEmpList2"];

                        SPListItem spItem = list.Items.Add();
                        spItem["empname"] = (intcount + 1).ToString();



    But Transaction scope is not working.

    I want use both Linq and sharepoint classes

    Plz suggest me solution.



    Tuesday, December 13, 2011 5:33 AM


  • SharePoint doesn't support transactions out of the box. If you really need them, you need to build your own transactions resource manager. The following link discusses this in great detail: http://www.loisandclark.eu/Pages/transactions.aspx
    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    • Proposed as answer by Margriet Bruggeman Tuesday, December 13, 2011 5:47 AM
    • Marked as answer by Wayne Fan Wednesday, December 21, 2011 6:44 AM
    Tuesday, December 13, 2011 5:46 AM
  • Yes Margriet right as there is no OOB transaction support in sharepoint.

    Although there are some possible workarounds for it like use of list version etc..

    Refer below links for that


    But truly transaction model is still not part of sharepoint 2010.

    Regards, Dharnendra Shah "strong belief is the only way to success"
    • Marked as answer by Wayne Fan Wednesday, December 21, 2011 6:44 AM
    Tuesday, December 13, 2011 6:07 AM

All replies