Esempio n. 1
0
        /// <summary>
        /// 同步查询操作
        ///
        ///
        /// </summary>
        /// <typeparam name="T">实体</typeparam>
        /// <param name="connection">连接字符串</param>
        /// <param name="cmd">sql语句</param>
        /// <param name="param">参数</param>
        /// <param name="flag">true存储过程,false sql语句</param>
        /// <returns>object</returns>
        public object ExecuteScalar <T>(string cmd, DynamicParameters param = null, bool flag = false) where T : class, new()
        {
            object result = null;

            using (var con = new MySqlFactory().DataBaseConnection(_connectionStr))
            {
                result = con.ExecuteScalar(cmd, param, null, null, flag ? CommandType.StoredProcedure : CommandType.Text);
            }
            return(result);
        }
Esempio n. 2
0
        public object ExecuteScalar(string cmd, DynamicParameters param = null, bool flag = false)
        {
            WriterLog(cmd);
            object result = null;

            using (var con = new MySqlFactory().DataBaseConnection(_connectionStr))
            {
                result = con.ExecuteScalar(cmd.ToLower(), param, null, null, flag ? CommandType.StoredProcedure : CommandType.Text);
            }
            return(result);
        }