using ReC.Domain.Attributes; using ReC.Infrastructure.Exceptions; namespace ReC.Infrastructure.Options.Shared; public record EntityBaseOptions() { public Dictionary ColumnMappings { get; init; } = []; public IEnumerable PropertyNames => ColumnMappings.Select(col => col.Key); public IEnumerable ColumnNames => ColumnMappings.Select(col => col.Value); public void EnsureProperties(IEnumerable propertyNames) { var missingProperties = propertyNames.Except(PropertyNames).ToList(); if (missingProperties.Count != 0) throw new DbModelConfigurationException($"The following properties are not configured: {string.Join(", ", missingProperties)}"); } public void EnsureProperties(params string[] propertyNames) => EnsureProperties(propertyNames.AsEnumerable()); public void EnsureProperties() { var propertyNames = typeof(T) .GetProperties() .Where(prop => Attribute.IsDefined(prop, typeof(MustConfiguredAttribute))) .Select(prop => prop.Name); EnsureProperties(propertyNames); } }