Release v1.0.0 #16

Merged
Wesser merged 492 commits from release/v1.0.0 into master 2025-02-12 09:19:32 +03:00
188 changed files with 5778 additions and 64 deletions
Showing only changes of commit 7c79f7d840 - Show all commits

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace Mirea.Api.DataAccess.Persistence.Common;
public static class ModelBuilderExtensions
{
public static void ApplyConfiguration(this ModelBuilder modelBuilder, object configuration)
{
var applyGenericMethod = typeof(ModelBuilder)
.GetMethods()
.First(m => m.Name == "ApplyConfiguration" &&
m.GetParameters().Any(p => p.ParameterType.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>)));
var entityType = configuration.GetType().GetInterfaces()
.First(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))
.GetGenericArguments()[0];
var applyConcreteMethod = applyGenericMethod.MakeGenericMethod(entityType);
applyConcreteMethod.Invoke(modelBuilder, [configuration]);
}
}