Naruto Reddy

Naruto Reddy

  • NA
  • 123
  • 36.6k

Achieve ADDorUpdate() using EF Core

Jun 18 2020 6:34 AM
Hello Experts, 
 
I want to achieve the ADDorUpdate() method in Generic repository using EF Core like below?
Can anyone help me?
public virtual void AddOrUpdate(T entity)
{
#region Argument Validation
if (entity == null)
{
throw new ArgumentNullException("entity");
}
#endregion
DbSet.AddOrUpdate(e => e.Id, entity);
this.DbContext.SaveChanges();
}