diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs
index 9c87aa2..7240e1e 100644
--- a/Database-Attribute_System/ClassAction.cs
+++ b/Database-Attribute_System/ClassAction.cs
@@ -36,7 +36,6 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
return cachedDbObject;
}
-
///
/// Fills an given dbObject with given data
/// Data-attribute-names and class-fieldNames have to match! (non case-sensitive)
@@ -44,6 +43,21 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
/// Given object (marked with Db-attributes)
/// The data
+ /// Key-name of data
+ public static void FillObject(T classObject, string key, object data)
+ {
+ Dictionary dicData = new Dictionary();
+ dicData.Add(key, data);
+ FillObject(classObject, dicData);
+ }
+ ///
+ /// Fills an given dbObject with given data
+ /// Data-attribute-names and class-fieldNames have to match! (non case-sensitive)
+ ///
+ ///
+ /// Given object (marked with Db-attributes)
+ /// The data
+ /// Key-name of data
public static void FillObject(T classObject, Dictionary data)
{
Type classType = classObject.GetType();
@@ -90,8 +104,11 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
/// Gets an dbObject by primaryKey/s
///
///
- /// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// The classType (marked with Db-attributes)
+ /// Name of the primaryKey
+ /// Value of the primaryKey
+ /// KeyData of multiple primaryKeys
+ /// Function to handle query-calls
public static T GetByPrimaryKey(Type classType, object primaryKeyValue, Func>> queryExecutor) where T : new()
{
// Read dbObject-attribute
@@ -102,6 +119,15 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
return GetByPrimaryKey(classType, dbObject.primaryKeyAttributes[0]._attributeName, primaryKeyValue, queryExecutor);
}
+ ///
+ /// Gets an dbObject by primaryKey/s
+ ///
+ ///
+ /// The classType (marked with Db-attributes)
+ /// Name of the primaryKey
+ /// Value of the primaryKey
+ /// KeyData of multiple primaryKeys
+ /// Function to handle query-calls
public static T GetByPrimaryKey(Type classType, string primaryKeyName, object primaryKeyValue, Func>> queryExecutor) where T : new()
{
Dictionary primaryKeyData = new Dictionary() { };
@@ -109,6 +135,15 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
return GetByPrimaryKey(classType, primaryKeyData, queryExecutor);
}
+ ///
+ /// Gets an dbObject by primaryKey/s
+ ///
+ ///
+ /// The classType (marked with Db-attributes)
+ /// Name of the primaryKey
+ /// Value of the primaryKey
+ /// KeyData of multiple primaryKeys
+ /// Function to handle query-calls
public static T GetByPrimaryKey(Type classType, Dictionary primaryKeyData, Func>> queryExecutor) where T: new()
{
// Read dbObject-attribute
@@ -161,7 +196,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
///
/// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// Function to handle query-calls
public static List GetList(Type classType, Func>> queryExecutor) where T : new()
{
// Read dbObject - attribute
@@ -182,18 +217,21 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
}
///
- /// Gets an dbObject by custom where-clause
+ /// Gets a list of dbObjects by attribute/s
///
///
- /// Given object (marked with Db-attributes)
- /// Custom where-clause params attached to query (SELECT * FROM tableName WHERE whereClause)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
- public static List GetListWithWhere(Type classType, Func>> queryExecutor, params object[] whereClause) where T : new()
+ /// Type of class
+ /// class-fields for select
+ /// Function to handle query-calls
+ /// List of dbObjects
+ public static List GetListByAttribute(Type classType, Dictionary fields, Func>> queryExecutor) where T : new()
{
- // Read dbObject - attribute
+ // Read dbObject-attribute
DbObject dbObject = ClassAction.Init(classType);
- string query = QueryBuilder.SelectWithWhere(dbObject._tableName, whereClause); // Generate query
+ Function.ConvertAttributeToDbAttributes(classType, fields);
+
+ string query = QueryBuilder.SelectByAttribute(dbObject._tableName, fields); // Generate query
List> dataSet = queryExecutor(query); // Execute
List objs = new List() { };
@@ -208,18 +246,18 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
}
///
- /// Gets an dbObject by full query
+ /// Gets an dbObject by custom where-clause
///
///
/// 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()
+ /// Custom where-clause params attached to query (SELECT * FROM tableName WHERE whereClause)
+ /// Function to handle query-calls
+ public static List GetListWithWhere(Type classType, Func>> queryExecutor, params object[] whereClause) where T : new()
{
// Read dbObject - attribute
DbObject dbObject = ClassAction.Init(classType);
- string query = QueryBuilder.BuildQuery(customQuery);
+ string query = QueryBuilder.SelectWithWhere(dbObject._tableName, whereClause); // Generate query
List> dataSet = queryExecutor(query); // Execute
List objs = new List() { };
@@ -233,27 +271,23 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
return objs; // Return list
}
-
///
- /// Gets a list of dbObjects by attribute/s
+ /// Gets an dbObject by full query
///
///
- /// Type of class
- /// class-fields for select
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
- /// List of dbObjects
- public static List GetListByAttribute(Type classType, Dictionary fields, Func>> queryExecutor) where T : new()
+ /// Given object (marked with Db-attributes)
+ /// Custom sql-query
+ /// Function to handle query-calls
+ public static List GetListWithQuery(Type classType, Func>> queryExecutor, params object[] customQuery) where T : new()
{
- // Read dbObject-attribute
+ // Read dbObject - attribute
DbObject dbObject = ClassAction.Init(classType);
- Function.ConvertAttributeToDbAttributes(classType, fields);
-
- string query = QueryBuilder.SelectByAttribute(dbObject._tableName, fields); // Generate query
+ string query = QueryBuilder.BuildQuery(customQuery);
List> dataSet = queryExecutor(query); // Execute
List objs = new List() { };
- foreach(Dictionary data in dataSet)
+ foreach (Dictionary data in dataSet)
{
T obj = new T(); // New object
FillObject(obj, data); // Fill it
@@ -271,7 +305,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
///
/// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// Function to handle query-calls
public static void ResolveByPrimaryKey(T classObject, Func>> queryExecutor, bool throwExceptions = true)
{
string query = QueryBuilder.SelectByPrimaryKey(classObject); // Generate query
@@ -290,7 +324,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
///
/// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// Function to handle query-calls
/// Determents how deep resolving will be executed
public static void ResolveForeignKeys(T classObject, Func>> queryExecutor, int max_depth = 1) where T: new()
{
@@ -473,7 +507,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
///
/// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// Function to handle query-calls
/// Determents how deep resolving will be executed (if the corresponding foreignKey-object is resolved)
public static void Update(T classObject, Func>> queryExecutor, int max_depth = 1)
{
@@ -500,7 +534,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
///
/// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// Function to handle query-calls
/// Determents how deep insertion will be executed (if the corresponding foreignKey-object is resolved)
public static void Insert(T classObject, Func>> queryExecutor, int max_depth = 1)
{
@@ -528,7 +562,7 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
///
///
/// Given object (marked with Db-attributes)
- /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// Function to handle query-calls
/// Determents how deep deletion will be executed (if the corresponding foreignKey-object is resolved)
public static void Delete(T classObject, Func>> queryExecutor, int max_depth = 1)
{