NejCommon.NET/Utils/AutoMapPropertyUtils.cs

21 lines
638 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using NejAccountingAPI.Models;
namespace AutoMapProperty;
public class AutoMapPropertyUtils
{
public static T Create<T>(IServiceProvider provider) where T : class
{
var appDb = provider.GetRequiredService<AppDbContext>();
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<AppDbContext>();
return appDb.Create<T, TParent>(parent, name);
}
}