From 41ba5e625d22543a4531df749abc3e74da6aaef1 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 20 Dec 2022 19:25:02 +0800 Subject: Develop secret api. v50 --- .../CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (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 d1958e5..1a2a055 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -62,9 +62,21 @@ public class CrudService : IDisposable where TEntity : class return result.Single(); } + public IInsertClause ConvertEntityToInsertClauses(TEntity entity) + { + var result = new InsertClause(); + foreach (var column in _table.PropertyColumns) + { + var value = column.PropertyInfo!.GetValue(entity); + result.Add(column.ColumnName, value); + } + return result; + } + public string Create(TEntity entity) { - var key = _table.Insert(_dbConnection, entity); + var insertClause = ConvertEntityToInsertClauses(entity); + var key = _table.Insert(_dbConnection, insertClause); return (string)key; } -- cgit v1.2.3