This commit is contained in:
454313500@qq.com
2021-03-20 21:56:15 +08:00
parent 2e5b991db0
commit 367f8f8830
16 changed files with 240 additions and 50 deletions

View File

@@ -15,6 +15,7 @@ namespace CC.Yi.BLL
{
CurrentDal = cd;
}
public IQueryable<T> GetAllEntities()
{
return CurrentDal.GetAllEntities();
@@ -49,12 +50,24 @@ namespace CC.Yi.BLL
return entity;
}
public bool Add(IEnumerable<T> entities)
{
CurrentDal.AddRange(entities);
return DbSession.SaveChanges() > 0;
}
public bool Update(T entity)
{
CurrentDal.Update(entity);
return DbSession.SaveChanges() > 0;
}
public bool Update(T entity, params string[] propertyNames)
{
CurrentDal.Update(entity,propertyNames);
return DbSession.SaveChanges() > 0;
}
public bool Delete(T entity)
{
CurrentDal.Delete(entity);
@@ -73,14 +86,24 @@ namespace CC.Yi.BLL
return DbSession.SaveChanges() > 0;
}
public int DeleteList(List<int> ids)
public bool Delete(IEnumerable<int> ids)
{
foreach (var id in ids)
{
CurrentDal.Detete(id);
}
return DbSession.SaveChanges();//这里把SaveChanges方法提到了循环体外自然就与数据库交互一次
return DbSession.SaveChanges()>0;
}
public bool Delete(Expression<Func<T, bool>> where)
{
IQueryable<T> entities = CurrentDal.GetEntities(where);
if (entities != null)
{
CurrentDal.DeteteRange(entities);
return DbSession.SaveChanges()>0;
}
return false;
}
}
}