92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using JY.DAL.Repository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace JY.DAL.Service
|
|
{
|
|
public class Service<T> : IService<T> where T : class, new()
|
|
{
|
|
protected readonly IRepository<T> _repository;
|
|
|
|
public Service(IRepository<T> repository)
|
|
{
|
|
_repository = repository;
|
|
}
|
|
|
|
public T GetById(object id)
|
|
{
|
|
return _repository.GetById(id);
|
|
}
|
|
|
|
public T GetSingle(Expression<Func<T, bool>> predicate)
|
|
{
|
|
return _repository.GetSingle(predicate);
|
|
}
|
|
|
|
public List<T> GetList()
|
|
{
|
|
return _repository.GetList();
|
|
}
|
|
|
|
public List<T> GetList(Expression<Func<T, bool>> predicate)
|
|
{
|
|
return _repository.GetList(predicate);
|
|
}
|
|
|
|
public List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null)
|
|
{
|
|
return _repository.GetListPaged(pageIndex, pageSize, out totalCount, predicate, orderBy);
|
|
}
|
|
|
|
public int Insert(T entity)
|
|
{
|
|
return _repository.Insert(entity);
|
|
}
|
|
|
|
public int Insert(List<T> entities)
|
|
{
|
|
return _repository.Insert(entities);
|
|
}
|
|
|
|
public int Update(T entity)
|
|
{
|
|
return _repository.Update(entity);
|
|
}
|
|
|
|
public int Update(T entity, Expression<Func<T, bool>> whereExpression)
|
|
{
|
|
return _repository.Update(entity, whereExpression);
|
|
}
|
|
|
|
public int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
|
|
{
|
|
return _repository.Update(columns, whereExpression);
|
|
}
|
|
|
|
public int Delete(object id)
|
|
{
|
|
return _repository.Delete(id);
|
|
}
|
|
|
|
public int Delete(Expression<Func<T, bool>> predicate)
|
|
{
|
|
return _repository.Delete(predicate);
|
|
}
|
|
|
|
public int Delete(List<T> entities)
|
|
{
|
|
return _repository.Delete(entities);
|
|
}
|
|
|
|
public bool Any(Expression<Func<T, bool>> predicate)
|
|
{
|
|
return _repository.Any(predicate);
|
|
}
|
|
|
|
public int Count(Expression<Func<T, bool>> predicate = null)
|
|
{
|
|
return _repository.Count(predicate);
|
|
}
|
|
}
|
|
} |