internal static Task <int> DeleteAsync <T>(this IDbCommand dbCmd, Expression <Func <T, bool> > where, CancellationToken token) { var q = dbCmd.GetDialectProvider().SqlExpression <T>(); q.Where(where); return(dbCmd.DeleteAsync(q, token)); }
internal static Task <int> DeleteAsync <T>(this IDbCommand dbCmd, Expression <Func <T, bool> > where, CancellationToken token) { var ev = OrmLiteConfig.DialectProvider.SqlExpression <T>(); ev.Where(where); return(dbCmd.DeleteAsync(ev, token)); }
public async virtual Task DeleteAsync(CancellationToken cancellationToken = default) { Guard.NotNull(Context.Entity, nameof(Context.Entity), $"Call {nameof(GetAsync)} first to instantiate entity"); Guard.NotTrue(Options.AsNoTracking, nameof(Options.AsNoTracking), $"Cannot delete entity with option '{nameof(Options.AsNoTracking)}' set to 'true'"); var stopwatch = Context.PerformanceMeasurements.Start(nameof(DeleteAsync)); try { Context.EditMode = EditMode.Delete; await ExecuteBeforeDeleteHooks(cancellationToken); await ValidateAsync(Context.EditMode, cancellationToken); if (Context.Entity is ISoftDeleteEntity softDeleteEntity && !Options.DisableSoftDelete) { softDeleteEntity.MarkAsDeleted(CurrentUser.Id, DateTime.UtcNow); await DbCommand.UpdateAsync(Context.Entity, cancellationToken); } else { await DbCommand.DeleteAsync(Context.Entity, cancellationToken); } await ExecuteAfterDeleteHooks(cancellationToken); }
internal static Task <int> DeleteAsync <T>(this IDbCommand dbCmd, T filter, CancellationToken token) { return(dbCmd.DeleteAsync <T>((object)filter, token)); }
internal static Task <int> DeleteAsync <T>(this IDbCommand dbCmd, Func <SqlExpression <T>, SqlExpression <T> > where, CancellationToken token) { return(dbCmd.DeleteAsync(where (dbCmd.GetDialectProvider().SqlExpression <T>()), token)); }