相关疑难解决方法(0)

EF Core 中 AddorUpdate 方法的替代方法是什么?

我想使用如下所示的 EF Core 在通用存储库中实现 ADDorUpdate() 方法?谁能帮我?

  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();
    }
Run Code Online (Sandbox Code Playgroud)

c# generics repository-pattern entity-framework-core asp.net-core

8
推荐指数
1
解决办法
6910
查看次数