v3.0.1
v3.0.1
This commit is contained in:
@@ -6,19 +6,26 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC.Yi.BLL
|
||||
{
|
||||
public class BaseBll<T> : IBaseBll<T> where T : class, new()
|
||||
{
|
||||
public IBaseDal<T> CurrentDal;
|
||||
public DbContext DbSession;
|
||||
public DbContext Db;
|
||||
public BaseBll(IBaseDal<T> cd, DataContext _Db)
|
||||
{
|
||||
CurrentDal = cd;
|
||||
DbSession = _Db;
|
||||
Db = _Db;
|
||||
}
|
||||
|
||||
|
||||
public async Task<T> GetEntityById(int id)
|
||||
{
|
||||
return await CurrentDal.GetEntityById(id);
|
||||
}
|
||||
|
||||
|
||||
public IQueryable<T> GetAllEntities()
|
||||
{
|
||||
return CurrentDal.GetAllEntities();
|
||||
@@ -40,7 +47,6 @@ namespace CC.Yi.BLL
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc)
|
||||
{
|
||||
return CurrentDal.GetPageEntities(pageSize, pageIndex, out total, whereLambda, orderByLambda, isAsc);
|
||||
@@ -48,38 +54,38 @@ namespace CC.Yi.BLL
|
||||
|
||||
public T Add(T entity)
|
||||
{
|
||||
CurrentDal.Add(entity);
|
||||
DbSession.SaveChanges();
|
||||
return entity;
|
||||
T entityData= CurrentDal.Add(entity);
|
||||
Db.SaveChanges();
|
||||
return entityData;
|
||||
}
|
||||
|
||||
public bool Add(IEnumerable<T> entities)
|
||||
{
|
||||
CurrentDal.AddRange(entities);
|
||||
return DbSession.SaveChanges() > 0;
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
|
||||
public bool Update(T entity)
|
||||
{
|
||||
CurrentDal.Update(entity);
|
||||
return DbSession.SaveChanges() > 0;
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
|
||||
public bool Update(T entity, params string[] propertyNames)
|
||||
{
|
||||
CurrentDal.Update(entity,propertyNames);
|
||||
return DbSession.SaveChanges() > 0;
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
|
||||
public bool Delete(T entity)
|
||||
{
|
||||
CurrentDal.Delete(entity);
|
||||
return DbSession.SaveChanges() > 0;
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
public bool Delete(int id)
|
||||
{
|
||||
CurrentDal.Detete(id);
|
||||
return DbSession.SaveChanges() > 0;
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
|
||||
public bool Delete(IEnumerable<int> ids)
|
||||
@@ -88,7 +94,7 @@ namespace CC.Yi.BLL
|
||||
{
|
||||
CurrentDal.Detete(id);
|
||||
}
|
||||
return DbSession.SaveChanges()>0;
|
||||
return Db.SaveChanges()>0;
|
||||
}
|
||||
public bool Delete(Expression<Func<T, bool>> where)
|
||||
{
|
||||
@@ -97,7 +103,7 @@ namespace CC.Yi.BLL
|
||||
{
|
||||
CurrentDal.DeteteRange(entities);
|
||||
|
||||
return DbSession.SaveChanges()>0;
|
||||
return Db.SaveChanges()>0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user