diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs index 206c3f0..41349c1 100644 --- a/Database-Attribute_System/ClassAction.cs +++ b/Database-Attribute_System/ClassAction.cs @@ -230,6 +230,8 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System { string query = QueryBuilder.SelectByPrimaryKey(classObject); // Generate query List> dataSet = queryExecutor(query); // Execute + + if (dataSet.Count == 0) throw new InvalidOperationException($"Cannot fetch '{typeof(T).Name}' by primary key/s. No results!"); FillObject(classObject, dataSet[0]); // Fill the object } @@ -241,7 +243,6 @@ 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] /// Determents how deep resolving will be executed - /// This checks if any class-field and data-attribute does not exists in either (Slower) public static void ResolveForeignKeys(T classObject, Func>> queryExecutor, int max_depth = 1) where T: new() { Type classType = classObject.GetType();