public static void ConfigureEfCoreEntity( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] EntityTypeBuilder typeBuilder) { Check.NotNull(objectExtensionManager, nameof(objectExtensionManager)); Check.NotNull(typeBuilder, nameof(typeBuilder)); var objectExtension = objectExtensionManager.GetOrNull(typeBuilder.Metadata.ClrType); if (objectExtension == null) { return; } foreach (var property in objectExtension.GetProperties()) { var efCoreMapping = property.GetEfCoreMappingOrNull(); if (efCoreMapping == null) { continue; } /* Prevent multiple calls to the entityTypeBuilder.Property(...) method */ if (typeBuilder.Metadata.FindProperty(property.Name) != null) { continue; } var propertyBuilder = typeBuilder.Property(property.Type, property.Name); efCoreMapping.PropertyBuildAction?.Invoke(propertyBuilder); } }
public static ObjectExtensionPropertyInfo GetPropertyOrNull( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] Type objectType, [NotNull] string propertyName) { Check.NotNull(objectExtensionManager, nameof(objectExtensionManager)); Check.NotNull(objectType, nameof(objectType)); Check.NotNull(propertyName, nameof(propertyName)); return(objectExtensionManager .GetOrNull(objectType)? .GetPropertyOrNull(propertyName)); }
public static ImmutableList <ObjectExtensionPropertyInfo> GetProperties( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] Type objectType) { Check.NotNull(objectExtensionManager, nameof(objectExtensionManager)); Check.NotNull(objectType, nameof(objectType)); var extensionInfo = objectExtensionManager.GetOrNull(objectType); if (extensionInfo == null) { return(EmptyPropertyList); } return(extensionInfo.GetProperties()); }