v1.0.1
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user