diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs
index 29a784c..c3f4a61 100644
--- a/Database-Attribute_System/ClassAction.cs
+++ b/Database-Attribute_System/ClassAction.cs
@@ -457,5 +457,89 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
}
}
}
+
+
+ ///
+ /// Updates class to database-object
+ /// Only works with primary-key/s!
+ ///
+ ///
+ /// Given object (marked with Db-attributes)
+ /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// 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)
+ {
+ // Read dbObject-attribute
+ DbObject dbObject = ClassAction.Init(classObject.GetType());
+
+ if(max_depth-1 > 0)
+ {
+ // Update all foreignObjects before handling myself
+ foreach (DbForeignObject foreignObject in dbObject.foreignObjectAttributes)
+ {
+ object foreignObjectRef = foreignObject.parentField.GetValue(classObject);
+ if (foreignObjectRef != null)
+ Update(foreignObjectRef, queryExecutor, max_depth - 1);
+ }
+ }
+
+ string updateQuery = QueryBuilder.UpdateByPrimaryKey(classObject);
+ queryExecutor.Invoke(updateQuery);
+ }
+
+ ///
+ /// Inserts class to database-object
+ ///
+ ///
+ /// Given object (marked with Db-attributes)
+ /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// 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)
+ {
+ // Read dbObject-attribute
+ DbObject dbObject = ClassAction.Init(classObject.GetType());
+
+ if (max_depth - 1 > 0)
+ {
+ // Update all foreignObjects before handling myself
+ foreach (DbForeignObject foreignObject in dbObject.foreignObjectAttributes)
+ {
+ object foreignObjectRef = foreignObject.parentField.GetValue(classObject);
+ if (foreignObjectRef != null)
+ Insert(foreignObjectRef, queryExecutor, max_depth - 1);
+ }
+ }
+
+ string insertQuery = QueryBuilder.InsertAttributesByObject(classObject);
+ queryExecutor.Invoke(insertQuery);
+ }
+
+ ///
+ /// Deletes class from database-object
+ /// Only works with primary-key/s!
+ ///
+ ///
+ /// Given object (marked with Db-attributes)
+ /// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
+ /// 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)
+ {
+ // Read dbObject-attribute
+ DbObject dbObject = ClassAction.Init(classObject.GetType());
+
+ if (max_depth - 1 > 0)
+ {
+ // Update all foreignObjects before handling myself
+ foreach (DbForeignObject foreignObject in dbObject.foreignObjectAttributes)
+ {
+ object foreignObjectRef = foreignObject.parentField.GetValue(classObject);
+ if (foreignObjectRef != null)
+ Delete(foreignObjectRef, queryExecutor, max_depth - 1);
+ }
+ }
+
+ string deleteQuery = QueryBuilder.DeleteByPrimaryKey(classObject);
+ queryExecutor.Invoke(deleteQuery);
+ }
}
}