From 8c82d535f1b4d76961cdb32b5235c05eae0d1c7d Mon Sep 17 00:00:00 2001 From: Railz Date: Fri, 4 Oct 2019 13:51:52 +0200 Subject: [PATCH] Added check if FillObject has missing attributes in class --- Database-Attribute_System/ClassAction.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs index af986ad..9c87aa2 100644 --- a/Database-Attribute_System/ClassAction.cs +++ b/Database-Attribute_System/ClassAction.cs @@ -54,6 +54,8 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System // Iterate through data foreach (KeyValuePair data_keySet in data) { + bool dataMatchFound = false; + // Interate through class-fields foreach (BaseAttribute baseAttribute in dbObject.baseAttributes) { @@ -72,13 +74,14 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System if (!(value is DBNull)) // Check if value is empty { baseAttribute.parentField.SetValue(classObject, value); - break; } - - + dataMatchFound = true; + break; } } + + if (!dataMatchFound) throw new InvalidOperationException($"Attribute '{data_keySet.Key}' has no match in object '{classObject.GetType().Name}'"); } }