Files
telegram-bot/Core/Extensions/RepositoryExtension.cs
T

14 lines
359 B
C#
Raw Normal View History

2023-07-29 15:03:45 +03:00
using Microsoft.EntityFrameworkCore;
2020-03-02 00:00:44 +04:00
2023-07-29 15:14:52 +03:00
namespace Kruzya.TelegramBot.Core.Extensions;
public static partial class RepositoryExtension
2020-03-02 00:00:44 +04:00
{
2023-07-29 15:14:52 +03:00
public static TEntity Create<TEntity>(this DbSet<TEntity> repository) where TEntity : class, new()
2020-03-02 00:00:44 +04:00
{
2023-07-29 15:14:52 +03:00
var entity = new TEntity();
repository.Add(entity);
2020-03-02 00:00:44 +04:00
2023-07-29 15:14:52 +03:00
return entity;
2020-03-02 00:00:44 +04:00
}
}