Add PropertyNames property to EntityBaseOptions
Introduce PropertyNames as a read-only property exposing the keys of ColumnMappings. Refactor EnsureProperties to use PropertyNames for improved clarity and maintainability.
This commit is contained in:
@@ -6,9 +6,11 @@ public record EntityBaseOptions()
|
||||
{
|
||||
public Dictionary<string, string> ColumnMappings { get; init; } = [];
|
||||
|
||||
public IEnumerable<string> PropertyNames => ColumnMappings.Select(col => col.Key);
|
||||
|
||||
public void EnsureProperties(IEnumerable<string> propertyNames)
|
||||
{
|
||||
var missingProperties = propertyNames.Except(ColumnMappings.Select(col => col.Key)).ToList();
|
||||
var missingProperties = propertyNames.Except(PropertyNames).ToList();
|
||||
|
||||
if (missingProperties.Count != 0)
|
||||
throw new InvalidOperationException($"The following properties are not configured: {string.Join(", ", missingProperties)}");
|
||||
|
||||
Reference in New Issue
Block a user