using System.Reflection; using Dapper; using Galaeth.Core.Attributes.EntityAnnotation; namespace Galaeth.DAL.Infrastructure; /// /// Entity attribute type mapper. /// public class EntityAttributeTypeMapper : FallbackTypeMapper { /// /// Initializes a new instance of the class. /// /// The entity type. public EntityAttributeTypeMapper(Type entityType) : base([ new CustomPropertyTypeMap( entityType, (type, columnName) => type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .FirstOrDefault( prop => prop.GetCustomAttributes(false) .OfType() .Any(attr => attr.Name.Equals(columnName, StringComparison.OrdinalIgnoreCase)))), new DefaultTypeMap(entityType) ]) { } }