practicekea_backend/microservices/_layers/data/Extenstions.cs

14 lines
504 B
C#
Raw Permalink Normal View History

2024-12-02 13:24:34 +00:00
namespace OnlineAssessment.Data
{
//https://stackoverflow.com/questions/31162576/entity-framework-add-if-not-exist-without-update
//public static class DbSetExtensions
//{
// public static T AddIfNotExists<T>(this DbSet<T> dbSet, T entity, Expression<Func<T, bool>> predicate = null) where T : class, new()
// {
// var exists = predicate != null ? dbSet.Any(predicate) : dbSet.Any();
// return !exists ? dbSet.Add(entity) : null;
// }
//}
}