diff --git a/Database-Attribute_System/ClassAction.cs b/Database-Attribute_System/ClassAction.cs
index d943356..c5a4f37 100644
--- a/Database-Attribute_System/ClassAction.cs
+++ b/Database-Attribute_System/ClassAction.cs
@@ -87,10 +87,13 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
/// Function to handle query-calls - Has to return Dictionary[attributeName, attributeValue]
public static T GetByPrimaryKey(Type classType, object primaryKeyValue, Func>> queryExecutor) where T : new()
{
- Dictionary primaryKeyData = new Dictionary() { };
- primaryKeyData.Add(null, primaryKeyValue);
+ // Read dbObject-attribute
+ DbObject dbObject = ClassAction.Init(classType);
- return GetByPrimaryKey(classType, primaryKeyData, queryExecutor);
+ if (dbObject.primaryKeyAttributes.Count < 1) throw new InvalidOperationException($"No primaryKey found in '{classType.Name}'");
+ if (dbObject.primaryKeyAttributes.Count > 1) throw new InvalidOperationException($"This 'GetByPrimaryKey' method only supports 1 primaryKey ('{dbObject.primaryKeyAttributes.Count}' found in '{classType.Name}')");
+
+ return GetByPrimaryKey(classType, dbObject.primaryKeyAttributes[0]._attributeName, primaryKeyValue, queryExecutor);
}
public static T GetByPrimaryKey(Type classType, string primaryKeyName, object primaryKeyValue, Func>> queryExecutor) where T : new()
{
@@ -107,6 +110,8 @@ namespace eu.railduction.netcore.dll.Database_Attribute_System
// Read dbObject-attribute
DbObject dbObject = ClassAction.Init(classType);
+ if (dbObject.primaryKeyAttributes.Count < 1) throw new InvalidOperationException($"No primaryKey found in '{classType.Name}'");
+
// iterate thru them to check and fill object
foreach (DbPrimaryKey primaryKeyAtt in dbObject.primaryKeyAttributes)
{