模型类

This commit is contained in:
橙子
2021-10-11 21:50:50 +08:00
parent 543800d0e7
commit 2093d1c78d
38 changed files with 652 additions and 185 deletions

View File

@@ -9,10 +9,10 @@ using Yi.Framework.Interface;
namespace Yi.Framework.Service
{
public class CCBaseServer<T> : IBaseService<T> where T : class, new()
public class BaseService<T> : IBaseService<T> where T : class, new()
{
public DbContext _Db;
public CCBaseServer(DbContext Db)
public BaseService(DbContext Db)
{
_Db = Db;
}
@@ -84,6 +84,12 @@ namespace Yi.Framework.Service
return await _Db.SaveChangesAsync() > 0;
}
public async Task<bool> UpdateListAsync(IEnumerable<T> entities)
{
_Db.Set<T>().UpdateRange(entities);
return await _Db.SaveChangesAsync() > 0;
}
public async Task<bool> DeleteAsync(T entity)
{
_Db.Set<T>().Remove(entity);
@@ -115,5 +121,10 @@ namespace Yi.Framework.Service
}
return false;
}
public async Task<T> GetEntity(Expression<Func<T, bool>> whereLambda)
{
return await _Db.Set<T>().Where(whereLambda).FirstOrDefaultAsync();
}
}
}