From 0f38c92bbe0e168f39b677dccba4cddfa80e8ae4 Mon Sep 17 00:00:00 2001 From: Railz Date: Mon, 1 Apr 2019 17:33:16 +0200 Subject: [PATCH] Added ResolveByPrimaryKey --- Database-Attribute_System/ClassAction.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs index 62c756a..0a9c6d4 100644 --- a/Database-Attribute_System/ClassAction.cs +++ b/Database-Attribute_System/ClassAction.cs @@ -48,9 +48,20 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System } + /// + /// Resolves an object with the database + /// Needs to have primaryKey/s set! + /// - Generates an query + /// - Sends an query via Func + /// - Fills the object with data + /// + /// + /// Given object (marked with Db-attributes) + /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue] + /// This disables errors when class-field has no data-attribute public static void ResolveByPrimaryKey(T classObject, Func> queryExecutor, bool ignoreDataAttributeNotInClass = false) { - string query = QueryBuilder.SelectByPrimaryKeys(classObject); + string query = QueryBuilder.SelectByPrimaryKey(classObject); Dictionary data = queryExecutor(query); FillObject(classObject, data, ignoreDataAttributeNotInClass); }