From dbef06668f4e8b81eb466faa11bb37709c79f09c Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 6 Dec 2022 18:32:21 +0800 Subject: Develop secret api. v14 --- .../CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs') diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs index bbd5e9a..7da6ac7 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -8,13 +8,13 @@ public class CrudService { protected readonly TableInfo _table; protected readonly IOptionsSnapshot _crupestApiOptions; - protected readonly ILogger> _logger; + private readonly ILogger> _logger; - public CrudService(IOptionsSnapshot crupestApiOptions, ILogger> logger) + public CrudService(ServiceProvider services) { _table = new TableInfo(typeof(TEntity)); - _crupestApiOptions = crupestApiOptions; - _logger = logger; + _crupestApiOptions = services.GetRequiredService>(); + _logger = services.GetRequiredService>>(); } public virtual string GetDbConnectionString() @@ -78,4 +78,12 @@ public class CrudService var sql = _table.GenerateUpdateSql(where, update, out parameters); return await connection.ExecuteAsync(sql, parameters); } + + public virtual async Task DeleteAsync(WhereClause? where) + { + var connection = await EnsureDatabase(); + DynamicParameters parameters; + var sql = _table.GenerateDeleteSql(where, out parameters); + return await connection.ExecuteAsync(sql, parameters); + } } -- cgit v1.2.3