/// <summary>
        /// General purpose static function that can be called from System.Data assembly
        /// </summary>
        /// <param name="tree">command tree</param>
        /// <param name="version">version</param>
        /// <param name="parameters">Parameters to add to the command tree corresponding
        /// to constants in the command tree. Used only in ModificationCommandTrees.</param>
        /// <returns>The string representing the SQL to be executed.</returns>
        internal static string GenerateSql(DbCommandTree tree, EFIngresStoreVersion version, out List <DbParameter> parameters, out CommandType commandType)
        {
            commandType = CommandType.Text;

            //Handle Query
            DbQueryCommandTree queryCommandTree = tree as DbQueryCommandTree;

            if (queryCommandTree != null)
            {
                SqlGenerator sqlGen = new SqlGenerator(version);
                parameters = null;
                return(sqlGen.GenerateSql((DbQueryCommandTree)tree));
            }

            //Handle Function
            DbFunctionCommandTree DbFunctionCommandTree = tree as DbFunctionCommandTree;

            if (DbFunctionCommandTree != null)
            {
                SqlGenerator sqlGen = new SqlGenerator(version);
                parameters = null;

                string sql = sqlGen.GenerateFunctionSql(DbFunctionCommandTree, out commandType);

                return(sql);
            }

            //Handle Insert
            DbInsertCommandTree insertCommandTree = tree as DbInsertCommandTree;

            if (insertCommandTree != null)
            {
                return(DmlSqlGenerator.GenerateInsertSql(insertCommandTree, out parameters));
            }

            //Handle Delete
            DbDeleteCommandTree deleteCommandTree = tree as DbDeleteCommandTree;

            if (deleteCommandTree != null)
            {
                return(DmlSqlGenerator.GenerateDeleteSql(deleteCommandTree, out parameters));
            }

            //Handle Update
            DbUpdateCommandTree updateCommandTree = tree as DbUpdateCommandTree;

            if (updateCommandTree != null)
            {
                return(DmlSqlGenerator.GenerateUpdateSql(updateCommandTree, out parameters));
            }

            throw new NotSupportedException("Unrecognized command tree type");
        }
 /// <summary>
 /// Basic constructor.
 /// </summary>
 /// <param name="storeVersion">server version</param>
 private SqlGenerator(EFIngresStoreVersion storeVersion)
 {
     this.storeVersion = storeVersion;
 }