70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using Competition.IBLL;
|
|
using Competition.IDAL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Competition.BLL
|
|
{
|
|
public class BaseService<T, TKey> : IBaseService<T, TKey> where T : class
|
|
{
|
|
private readonly IBaseRepository<T, TKey> _repository;
|
|
public BaseService(IBaseRepository<T, TKey> repository)
|
|
{
|
|
_repository = repository;
|
|
}
|
|
|
|
|
|
public T Find(TKey id)
|
|
{
|
|
return _repository.Find(id);
|
|
}
|
|
|
|
public T Find(Expression<Func<T, bool>> wherelamb)
|
|
{
|
|
return _repository.Find(wherelamb);
|
|
}
|
|
|
|
public IQueryable<T> LoadEntities(Expression<Func<T, bool>> whereLambda)
|
|
{
|
|
return _repository.LoadEntities(whereLambda);
|
|
}
|
|
|
|
public IQueryable<T> LoadPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderbyLambda, bool isAsc)
|
|
{
|
|
return _repository.LoadPageEntities(pageSize, pageIndex, out total, whereLambda, orderbyLambda, isAsc);
|
|
}
|
|
|
|
public int SaveChange()
|
|
{
|
|
return _repository.SaveChange();
|
|
}
|
|
|
|
public bool Update(T entity, bool isSaveChage = true)
|
|
{
|
|
return _repository.Update(entity, isSaveChage);
|
|
}
|
|
|
|
public int Add(T entity, bool isSaveChage = true)
|
|
{
|
|
return _repository.Add(entity, isSaveChage = true);
|
|
}
|
|
public int Delete(T entity, bool isSaveChage = true)
|
|
{
|
|
return _repository.Delete(entity, isSaveChage);
|
|
}
|
|
|
|
public int Delete(params int[] ids)
|
|
{
|
|
return _repository.Delete(ids);
|
|
}
|
|
public void Dispose()
|
|
{
|
|
_repository.Dispose();
|
|
}
|
|
}
|
|
}
|