Added check if FillObject has missing attributes in class

master
Railz 5 years ago
parent 56d8cea635
commit 8c82d535f1

@ -54,6 +54,8 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
// Iterate through data // Iterate through data
foreach (KeyValuePair<string, object> data_keySet in data) foreach (KeyValuePair<string, object> data_keySet in data)
{ {
bool dataMatchFound = false;
// Interate through class-fields // Interate through class-fields
foreach (BaseAttribute baseAttribute in dbObject.baseAttributes) 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 if (!(value is DBNull)) // Check if value is empty
{ {
baseAttribute.parentField.SetValue(classObject, value); 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}'");
} }
} }

Loading…
Cancel
Save