public static async Task <object> ExecuteScalarAsync(this AnyDbConnection cnn, Select query, IDbTransaction transaction = null, int?commandTimeout = default(int?))
        {
            string selectSql = GetSelectSql(cnn, query);

            if (!commandTimeout.HasValue)
            {
                commandTimeout = cnn.DefaultCommandTimeout;
            }
            DynamicParameters parameters = GetParameters(query.Query.CommandParams);

            return(await SqlMapper.ExecuteScalarAsync((IDbConnection)cnn, selectSql, (object)parameters, transaction, commandTimeout, (CommandType?)CommandType.Text));
        }
        public static async Task <long> ExecuteAsync(this AnyDbConnection cnn, Insert query, IDbTransaction transaction = null, int?commandTimeout = default(int?))
        {
            string sql = GetInsertSql(cnn, query);

            if (!commandTimeout.HasValue)
            {
                commandTimeout = cnn.DefaultCommandTimeout;
            }
            DynamicParameters parameters = GetParameters(query.Query.CommandParams);

            if (string.IsNullOrEmpty(query.Query.IdentityField))
            {
                return(Convert.ToInt64(await SqlMapper.ExecuteAsync((IDbConnection)cnn, sql, (object)parameters, transaction, commandTimeout, (CommandType?)CommandType.Text)));
            }
            return(Convert.ToInt64(await SqlMapper.ExecuteScalarAsync((IDbConnection)cnn, sql, (object)parameters, transaction, commandTimeout, (CommandType?)CommandType.Text)));
        }
示例#3
0
 public static Task <object> ExecuteScalarAsync(this IDbConnection cnn, string sql, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     TRACE(sql);
     return(SqlMapper.ExecuteScalarAsync(cnn, sql, param, transaction, commandTimeout, commandType));
 }