diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs index 41349c1..27750b3 100644 --- a/Database-Attribute_System/ClassAction.cs +++ b/Database-Attribute_System/ClassAction.cs @@ -162,7 +162,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System } /// - /// Gets an dbObject by primaryKey/s + /// Gets an dbObject by custom where-clause /// /// /// Given object (marked with Db-attributes) @@ -186,7 +186,34 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System return objs; // Return list } - + + /// + /// Gets an dbObject by full query + /// + /// + /// Given object (marked with Db-attributes) + /// Custom sql-query + /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue] + public static List GetListWithQuery(Type classType, Func>> queryExecutor, params object[] customQuery) where T : new() + { + // Read dbObject - attribute + DbObject dbObject = ClassAction.Init(classType); + + string query = QueryBuilder.BuildQuery(customQuery); + List> dataSet = queryExecutor(query); // Execute + + List objs = new List() { }; + foreach (Dictionary data in dataSet) + { + T obj = new T(); // New object + FillObject(obj, data); // Fill it + objs.Add(obj); // Add to list + } + + return objs; // Return list + } + + /// /// Gets a list of dbObjects by attribute/s /// @@ -194,7 +221,6 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System /// Type of class /// class-fields for select /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue] - /// This checks if any class-field and data-attribute does not exists in either (Slower) /// List of dbObjects public static List GetListByAttribute(Type classType, Dictionary fields, Func>> queryExecutor) where T : new() {