public static async Task <int> ExecuteAsync( this DbContext context, CancellationToken ct, string text, object parameters = null, int?timeout = null, CommandType?type = null ) { var command = new DapperEFCoreCommand( context, text, parameters, timeout, type, ct ); var connection = context.Database.GetDbConnection(); return(await connection.ExecuteAsync(command.Definition)); }
// Dont know if this works public static async Task <T> FirstOrDefaultAsync <T>( this DbContext context, CancellationToken ct, string text, object parameters = null, int?timeout = null, CommandType?type = null ) { Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true; var command = new DapperEFCoreCommand( context, text, parameters, timeout, type, ct ); var connection = context.Database.GetDbConnection(); return(await connection.QueryFirstOrDefaultAsync <T>(command.Definition)); }