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:
@@ -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)}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user