Add EnsureProperties method to EntityBaseOptions

Introduce EnsureProperties to validate required property names
against the Columns dictionary, throwing an exception if any
are missing. This helps enforce configuration completeness.
This commit is contained in:
2025-12-10 13:26:42 +01:00
parent 0588ba33d8
commit fb08a45c57

View File

@@ -3,4 +3,12 @@
public record EntityBaseOptions()
{
public Dictionary<string, string> Columns { get; init; } = [];
public void EnsureProperties(IEnumerable<string> propertyNames)
{
var missingProperties = propertyNames.Except(Columns.Select(col => col.Key)).ToList();
if (missingProperties.Count != 0)
throw new InvalidOperationException($"The following properties are not configured: {string.Join(", ", missingProperties)}");
}
}