标签:
常见的服务接口只需要继承基类就可以使用了
引用如下:
public interface IThemePageService : IDynamicService<ThemePage> {
}
就可以使用 上面的任何方法了
Resolve<IThemeConfigService>().GetList(r=>r.AppName=="User")
常见方法汇总
/// <summary> /// 获取列表 /// </summary> /// <param name="predicate">查询条件</param> /// <param name="sortOrder">排序方式</param> /// <returns></returns> IEnumerable<T> GetList(Expression<Func<T, bool>> predicate = null, Expression<Func<T, bool>> sortOrder = null); /// <summary> /// 查询单条记录 /// </summary> /// <param name="predicate">查询条件</param> /// <returns></returns> T GetSingle(Expression<Func<T, bool>> predicate); /// <summary> /// 删除系统 /// </summary> /// <param name="predicate">查询条件</param> ServiceResult Delete(Expression<Func<T, bool>> predicate); /// <summary> /// 查询分页 /// </summary> /// <param name="query"></param> /// <param name="predicate"></param> /// <returns></returns> PagedList<T> GetPagedList(QueryModel query, Expression<Func<T, bool>> predicate = null); /// <summary> /// 统计数量 /// </summary> /// <param name="predicate"></param> /// <returns></returns> long Count(Expression<Func<T, bool>> predicate); /// <summary> /// 添加单个实体 /// </summary> /// <param name="model"></param> /// <returns></returns> ServiceResult Add(T model); /// <summary> /// 更新单个实体 /// </summary> /// <param name="model"></param> /// <returns></returns> ServiceResult Update(T model); /// <summary> /// 批量添加多个实体 /// </summary> /// <param name="model"></param> /// <returns></returns> ServiceResult AddMany(IEnumerable<T> soucre); /// <summary> /// 批量更新多个实体 /// </summary> /// <param name="model"></param> /// <returns></returns> ServiceResult UpdateMany(Action<T> updateAction, Expression<Func<T, bool>> predicate=null);
一行代码添加GetList、GetSingle、Add、等数据库操作方法
标签:
原文地址:http://www.cnblogs.com/zkcloud/p/5631519.html