diff options
author | crupest <crupest@outlook.com> | 2022-12-17 19:07:23 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-12-20 20:32:53 +0800 |
commit | 7407875fb75bcd90f6f7ef54573483fe2f3cfb84 (patch) | |
tree | ed55de998706e6805f71614d20d2602d1b3b599f /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | |
parent | 4595650f6e36ff413bcb65f5419daf8f9bfee9de (diff) | |
download | crupest-7407875fb75bcd90f6f7ef54573483fe2f3cfb84.tar.gz crupest-7407875fb75bcd90f6f7ef54573483fe2f3cfb84.tar.bz2 crupest-7407875fb75bcd90f6f7ef54573483fe2f3cfb84.zip |
Develop secret api. v41
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs index 65085fd..d371c84 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -46,7 +46,7 @@ public class CrudService<TEntity> : IDisposable where TEntity : class return result; } - public TEntity GetByKey(string key) + public TEntity GetByKey(object key) { var result = _table.Select<TEntity>(_dbConnection, null, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key)); return result.Single(); @@ -58,4 +58,15 @@ public class CrudService<TEntity> : IDisposable where TEntity : class var key = _table.Insert(_dbConnection, insertClauses); return (string)key; } + + public void Update(object key, JsonElement jsonElement) + { + var updateClauses = _jsonHelper.ConvertJsonElementToUpdateClause(jsonElement); + _table.Update(_dbConnection, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key), updateClauses); + } + + public void DeleteByKey(object key) + { + _table.Delete(_dbConnection, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key)); + } } |