fix
This commit is contained in:
@@ -39,30 +39,34 @@ public class RepositoryBase<TEntity> where TEntity : class
|
||||
}
|
||||
|
||||
|
||||
protected async Task<TEntity?> GetAsync(Guid id)
|
||||
protected async Task<TEntity?> GetBaseAsync(Guid id)
|
||||
{
|
||||
return await _context.Set<TEntity>().FindAsync(id);
|
||||
}
|
||||
|
||||
protected async Task<int> AddAsync(TEntity entity)
|
||||
protected async Task<int> AddBaseAsync(TEntity entity)
|
||||
{
|
||||
await _context.Set<TEntity>().AddAsync(entity);
|
||||
//await _context.Set<TEntity>().AddAsync(entity);
|
||||
await _context.AddAsync(entity);
|
||||
return await SaveChangesAsync();
|
||||
}
|
||||
|
||||
protected int Add(TEntity entity)
|
||||
protected int AddBase(TEntity entity)
|
||||
{
|
||||
_context.Set<TEntity>().Add(entity);
|
||||
//_context.Set<TEntity>().Add(entity);
|
||||
_context.Add(entity);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
protected int Remove(TEntity entity)
|
||||
protected int RemoveBase(TEntity entity)
|
||||
{
|
||||
_context.Set<TEntity>().Remove(entity);
|
||||
_context.Entry(entity).State = EntityState.Deleted;
|
||||
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
protected async Task<int> UpdateAsync(TEntity entity)
|
||||
protected async Task<int> UpdateBaseAsync(TEntity entity)
|
||||
{
|
||||
_context.Attach(entity);
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
@@ -70,9 +74,11 @@ public class RepositoryBase<TEntity> where TEntity : class
|
||||
return await SaveChangesAsync();
|
||||
}
|
||||
|
||||
protected int Update(TEntity entity)
|
||||
protected int UpdateBase(TEntity entity)
|
||||
{
|
||||
_context.Attach(entity);
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
|
||||
return SaveChanges();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user