Files
Yi.Admin/CC.Yi.IDAL/IBaseDal.cs

70 lines
1.7 KiB
C#
Raw Normal View History

2021-03-20 14:12:24 +08:00
using System;
2021-03-20 21:56:15 +08:00
using System.Collections.Generic;
2021-03-20 14:12:24 +08:00
using System.Linq;
using System.Linq.Expressions;
namespace CC.Yi.IDAL
{
public interface IBaseDal<T> where T : class, new()
{
2021-03-20 15:02:23 +08:00
#region
//得到全部实体
#endregion
IQueryable<T> GetAllEntities();
2021-03-20 14:12:24 +08:00
#region
//通过表达式得到实体
#endregion
IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda);
#region
2021-03-20 15:02:23 +08:00
//通过表达式得到实体,分页版本
2021-03-20 14:12:24 +08:00
#endregion
2021-03-20 15:02:23 +08:00
IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
2021-03-20 14:12:24 +08:00
#region
2021-03-20 15:02:23 +08:00
//通过表达式统计数量
2021-03-20 14:12:24 +08:00
#endregion
2021-03-20 15:02:23 +08:00
int GetCount(Expression<Func<T, bool>> whereLambda);
2021-03-20 14:12:24 +08:00
#region
2021-03-20 15:02:23 +08:00
//通过表达式分组
2021-03-20 14:12:24 +08:00
#endregion
2021-03-20 15:02:23 +08:00
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
2021-03-20 14:12:24 +08:00
#region
2021-03-20 15:02:23 +08:00
//添加单个实体
2021-03-20 14:12:24 +08:00
#endregion
T Add(T entity);
2021-03-20 21:56:15 +08:00
#region
//添加多个实体
#endregion
bool AddRange(IEnumerable<T> entities);
2021-03-20 14:12:24 +08:00
#region
2021-03-20 15:02:23 +08:00
//更新单个实体
2021-03-20 14:12:24 +08:00
#endregion
bool Update(T entity);
2021-03-20 21:56:15 +08:00
#region
//更新单个实体部分属性
#endregion
bool Update(T entity, params string[] propertyNames);
2021-03-20 14:12:24 +08:00
#region
2021-03-20 15:02:23 +08:00
//删除单个实体
2021-03-20 14:12:24 +08:00
#endregion
bool Delete(T entity);
#region
2021-03-20 15:02:23 +08:00
//通过id删除实体
2021-03-20 14:12:24 +08:00
#endregion
bool Detete(int id);
2021-03-20 21:56:15 +08:00
#region
//删除多个实体
#endregion
bool DeteteRange(IEnumerable<T> entity);
2021-03-20 14:12:24 +08:00
}
}