Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="parameterValues"></param>
        /// <param name="pagination"></param>
        /// <returns></returns>
        public override DataTable ExecutePaginationTable(SqlWrap sql, IDictionary <string, object> parameterValues, Pagination pagination)
        {
            ArgumentAssertion.IsNotNull(sql, "sql");
            ArgumentAssertion.IsNotNull(pagination, "pagination");

            Stopwatch stopwatch    = null;
            var       sqlProcessor = ObjectIOCFactory.GetSingleton <DataSettings>().SqlProcessor;

            if (sqlProcessor.EnableTrace)
            {
                stopwatch = Stopwatch.StartNew();
            }

            var sqlText = GetPaginationSql(sql, pagination);

            sqlText = this.TransformSql(sqlText, parameterValues);

            var dataSet    = MySqlHelper.ExecuteDataSet(this.ConnectionString, sqlText, sql.CommandTimeout, ConvertToDbParams(parameterValues));
            var totalCount = dataSet.Tables[0].Rows[0][0].Convert <int>();

            pagination.TotalCount = totalCount;

            if (sqlProcessor.EnableTrace)
            {
                stopwatch.Stop();
                sqlProcessor.Log(LogLevel.Trace, string.Format("[{0}]ExecuteSql({1})\r\n\t{2}", stopwatch.Elapsed, sql.FullName, sqlText), null);
            }

            return(dataSet.Tables[1]);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public override object ExecuteScalar(SqlWrap sql, IDictionary <string, object> parameterValues)
        {
            ArgumentAssertion.IsNotNull(sql, "sql");

            Stopwatch stopwatch    = null;
            var       sqlProcessor = ObjectIOCFactory.GetSingleton <DataSettings>().SqlProcessor;

            if (sqlProcessor.EnableTrace)
            {
                stopwatch = Stopwatch.StartNew();
            }

            var sqlText = this.TransformSql(sql.SqlText, parameterValues);

            var result = MySqlHelper.ExecuteScalar(this.ConnectionString, sqlText, sql.CommandTimeout, ConvertToDbParams(parameterValues));

            if (result == DBNull.Value)
            {
                result = null;
            }

            if (sqlProcessor.EnableTrace)
            {
                stopwatch.Stop();
                sqlProcessor.Log(LogLevel.Trace, string.Format("[{0}]ExecuteSql({1})\r\n\t{2}", stopwatch.Elapsed, sql.FullName, sqlText), null);
            }
            return(result);
        }