Beispiel #1
0
        public object[][] Execute(string connectionString)
        {
            var results        = new List <object[]>();
            var executionStack = new Stack <ICommandMultiAccessor>();

            //unravel the stack of commands
            ICommandMultiAccessor stackIndex = this;
            //hack to execute that last single command....
            ICommandAccessor <object> firstCommand = null;

            while (stackIndex != null)
            {
                executionStack.Push(stackIndex);
                if (stackIndex.PreviousMultiCommand == null)
                {
                    firstCommand = stackIndex.PreviousCommand;
                }
                stackIndex = stackIndex.PreviousMultiCommand;
            }

            using (var connection = new SqlConnection(connectionString))
            {
                connection.Open();
                results.Add(firstCommand.ExecuteConnection(connection));


                while (executionStack.Count > 0)
                {
                    results.Add(executionStack.Pop().ExecuteLocal(connection));
                }
            }

            return(results.ToArray());
        }