aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs')
-rw-r--r--docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs14
1 files changed, 13 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 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<TEntity> : 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;
}