NejCommon.NET/Utils/AutoMapPropertyUtils.cs
2026-09-16 16:39:59 +02:00

21 lines
637 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using NejCommon.Models;
namespace AutoMapProperty;
public class AutoMapPropertyUtils
{
public static T Create<T>(IServiceProvider provider) where T : class
{
var appDb = provider.GetRequiredService<CommonDbContext>();
return appDb.Create<T>();
}
public static T Create<T, TParent>(IServiceProvider provider, TParent parent, string name) where T : class, new() where TParent : class
{
var appDb = provider.GetRequiredService<CommonDbContext>();
return appDb.Create<T, TParent>(parent, name);
}
}