Wrapping a transaction around 2 StoredProcedure calls?

Posts   
 
    
ianvink
User
Posts: 393
Joined: 15-Dec-2006
# Posted on: 06-Feb-2013 00:58:14   

Using the Entity Framework 4.0

I have 2 Stored Procedure Calls generated by LLBL which look like this:

        public int CallFIRST(System.String userId, System.String clientIds)
        {
            var cmd = CreateStoredProcCallCommand("[dbo].[usp_ABC]", true);
            AddParameter(cmd, "@USER_ID", 64, ParameterDirection.Input, userId);
            var toReturn = ExecuteNonQueryCommand(cmd);
            return toReturn;
        }

        public int CallSECOND(System.String userId, System.String clientIds)
        {
            var cmd = CreateStoredProcCallCommand("[dbo].[usp_123]", true);
            AddParameter(cmd, "@USER_ID", 64, ParameterDirection.Input, userId);
            var toReturn = ExecuteNonQueryCommand(cmd);
            return toReturn;
        }

How do I call them both inside 1 transaction?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Feb-2013 06:46:11   

You could create your own method (CallMyTwoSPs) in a partial class, get the connection, open it, begin the transaction, call yous two SPs methods, then commit.

David Elizondo | LLBLGen Support Team