示例#1
0
        public DataTable FillForSQL(string sql, QueryParams queryParams)
        {
            var       dynamicParams = new DynamicParameters();
            DataTable table         = new DataTable();

            bool getSQL = false;

            if (queryParams != null && queryParams.ContainsQueryName(AppSettings.GET_SQL_EXCEPTION))
            {
                queryParams.RemoveQueryDefine(AppSettings.GET_SQL_EXCEPTION);
                getSQL = true;
            }

            string tsql = FormatSqlForSQL(sql, queryParams, dynamicParams);

            if (getSQL)
            {
                ThrowSqlException("SQL语句查看,请点击详细信息。\r\n SQL语句如下:\r\n-------------------------------------------------------------------------------\r\n" + tsql, dynamicParams, null);
            }
            return(FillSql(tsql, dynamicParams));
        }
示例#2
0
        /// <summary>
        /// 动态参数的查询模式
        /// </summary>
        /// <param name="key">xml的节点名称</param>
        /// <param name="queryParams">动态多参数,分先后顺序</param>
        /// <param name="select">select列过滤</param>
        /// <param name="args">格式化脚本string.Format(sql, args)</param>
        /// <returns></returns>
        public string FillPara(string sql, QueryParams queryParams, string select = null, params string[] args)
        {
            var       dynamicParams = new DynamicParameters();
            DataTable table         = new DataTable();

            bool getSQL = false;

            if (queryParams != null && queryParams.ContainsQueryName(AppSettings.GET_SQL_EXCEPTION))
            {
                queryParams.RemoveQueryDefine(AppSettings.GET_SQL_EXCEPTION);
                getSQL = true;
            }

            string returnsql = FormatSql(sql, queryParams, select, dynamicParams, args);

            if (getSQL)
            {
                ThrowSqlException("SQL语句查看,请点击详细信息。\r\n SQLKey:" + 1 + "\r\n-------------------------------------------------------------------------------\r\n" + sql, dynamicParams, null);
            }

            return(returnsql);
        }