aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-12-17 19:07:23 +0800
committercrupest <crupest@outlook.com>2022-12-20 20:32:53 +0800
commit7407875fb75bcd90f6f7ef54573483fe2f3cfb84 (patch)
treeed55de998706e6805f71614d20d2602d1b3b599f /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs
parent4595650f6e36ff413bcb65f5419daf8f9bfee9de (diff)
downloadcrupest-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.cs13
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));
+ }
}