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;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CC.Yi.IBLL\CC.Yi.IBLL.csproj" />
|
||||
<ProjectReference Include="..\CC.Yi.IDAL\CC.Yi.IDAL.csproj" />
|
||||
<ProjectReference Include="..\CC.Yi.ViewModel\CC.Yi.ViewModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -15,15 +15,18 @@ namespace CC.Yi.BLL
|
||||
public studentBll(IBaseDal<student> cd,DataContext _Db):base(cd,_Db)
|
||||
{
|
||||
CurrentDal = cd;
|
||||
DbSession = _Db;
|
||||
Db = _Db;
|
||||
}
|
||||
}
|
||||
public partial class propBll : BaseBll<prop>, IpropBll
|
||||
{
|
||||
public propBll(IBaseDal<prop> cd,DataContext _Db):base(cd,_Db)
|
||||
|
||||
public async Task<bool> DelListByUpdateList(List<int> Ids)
|
||||
{
|
||||
CurrentDal = cd;
|
||||
DbSession = _Db;
|
||||
var entitys = await CurrentDal.GetEntities(u => Ids.Contains(u.id)).ToListAsync();
|
||||
foreach (var entity in entitys)
|
||||
{
|
||||
entity.is_delete = (short)ViewModel.Enum.DelFlagEnum.Deleted;
|
||||
}
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,19 @@ namespace CC.Yi.BLL
|
||||
public <#=k #>Bll(IBaseDal<<#=k #>> cd,DataContext _Db):base(cd,_Db)
|
||||
{
|
||||
CurrentDal = cd;
|
||||
DbSession = _Db;
|
||||
Db = _Db;
|
||||
}
|
||||
|
||||
public async Task<bool> DelListByUpdateList(List<int> Ids)
|
||||
{
|
||||
var entitys = await CurrentDal.GetEntities(u => Ids.Contains(u.id)).ToListAsync();
|
||||
foreach (var entity in entitys)
|
||||
{
|
||||
entity.is_delete = (short)ViewModel.Enum.DelFlagEnum.Deleted;
|
||||
}
|
||||
return Db.SaveChanges() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
<# } #>
|
||||
}
|
||||
Reference in New Issue
Block a user