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:
2025-12-10 13:52:16 +01:00
parent 48039b8fd5
commit 5a56125444

View File

@@ -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)}");