Exemplo 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>int</returns>
        public async Task <int> ExcuteNonQueryAsync <T>(string cmd, DynamicParameters param = null, bool flag = false) where T : class, new()
        {
            int result = 0;

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