/// <summary>
        ///
        /// </summary>
        /// <param name="dataTableOnly"></param>
        /// <param name="query"></param>
        /// <param name="tableName"></param>
        /// <param name="key"></param>
        /// <param name="returnSet"></param>
        /// <param name="tools"></param>
        /// <returns></returns>
        public static bool ExecuteQuery(
            bool dataTableOnly,
            string query,
            string tableName,
            string key,
            out DataReturnSet returnSet,
            ref DataAccessTools tools)
        {
            returnSet = null;
            if (tools == null)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(query))
            {
                return(false);
            }

            Dictionary <string, int> columns;
            List <List <object> >    data;
            DataTable dTable;

            if (!tools.ExecuteQuery(dataTableOnly, query, tableName, key,
                                    out columns, out data, out dTable))
            {
                return(false);
            }

            if (data != null)
            {
                //Create return set
                if (!dataTableOnly)
                {
                    returnSet = new DataReturnSet(columns, data);
                }
                else
                {
                    returnSet = new DataReturnSet(dTable);
                }
            }

            //Return true
            return(true);
        }
 public DataReturnSetRow(DataReturnSet rS, List <object> rowData)
 {
     this.parentRef  = rS;
     this.currentRow = rowData;
 }
 public DataReturnSetEnum(DataReturnSet returnSet)
 {
     this.returnSetInstance = returnSet;
     this.currentRowIdx     = -1;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataTableOnly"></param>
        /// <param name="query"></param>
        /// <param name="tableName"></param>
        /// <param name="key"></param>
        /// <param name="returnSet"></param>
        /// <param name="tools"></param>
        /// <param name="vars">
        /// The zero index and even indices are param names
        /// and the Odd indices are param values
        /// </param>
        /// <returns></returns>
        public static bool ExecuteVariableQuery(
            bool dataTableOnly,
            string query,
            string tableName,
            string key,
            out DataReturnSet returnSet,
            ref DataAccessTools tools,
            params PairType <string, string>[] vars)
        {
            returnSet = null;
            if (tools == null)
            {
                return(false);
            }
            tools.log(LogLevel.DEBUG, "DataAccessTools::ExecuteVariableQuery");
            if (string.IsNullOrEmpty(query))
            {
                tools.log(LogLevel.ERROR, "- Query is invalid");
                return(false);
            }
            tools.log(LogLevel.DEBUG, "- Executing query: {0}", query);

            Dictionary <string, int> columns;
            List <List <object> >    data;
            DataTable dTable;

            //Prepare variable query
            string finalQuery = PrepareVariableQuery(ref tools, query, vars);

            if (string.IsNullOrEmpty(finalQuery))
            {
                tools.log(LogLevel.ERROR, "- Variable query could not be generated");
                return(false);
            }

            //Log transformed query
            tools.log(LogLevel.INFO, "Transformed query: {0}", finalQuery);

            //Execute variable query
            if (!tools.ExecuteQuery(dataTableOnly, finalQuery, tableName, key,
                                    out columns, out data, out dTable))
            {
                return(false);
            }

            if (data != null)
            {
                //Create return set
                if (!dataTableOnly)
                {
                    returnSet = new DataReturnSet(columns, data);
                }
                else
                {
                    returnSet = new DataReturnSet(dTable);
                }
            }

            //Return true
            return(true);
        }