Esempio n. 1
0
        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="search"></param>
        /// <returns></returns>
        public IEnumerable <TEntity> Query <TEntity>(SearchSqlBuilder search)
        {
            //return default(TEntity);
            var _sqlTmpl = search.Build <TEntity>(this.DataContext);

            return(DataContext.Query <TEntity>(_sqlTmpl));
        }
Esempio n. 2
0
        /// <summary>
        /// 分页查询列表
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="search">查询条件中必须指定Order字段</param>
        /// <returns></returns>
        public Page <TEntity> QueryPage <TEntity>(SearchSqlBuilder search)
        {
            var _sqlTmpl = search.Build <TEntity>(this.DataContext);

            if (search.Pageing == null)
            {
                search.Pageing = search.DefaultPageInfo;
            }
            return(DataContext.Page <TEntity>(search.Pageing.PageIndex, search.Pageing.PageSize, _sqlTmpl));
        }
 /// <summary>
 /// 构建分页查询(act参数中必须调用order指定排序)
 /// </summary>
 /// <param name="search"></param>
 /// <param name="act">查询条件构建</param>
 /// <param name="pageIndex">当前页码</param>
 /// <param name="pageSize">每页条数(默认10)</param>
 /// <returns></returns>
 public static SearchSqlBuilder CreatePage(this SearchSqlBuilder search, Action <SqlBuilder> act, int pageIndex, int pageSize = 10)
 {
     search.QueryConditionAct = act;
     search.Pageing           = new SearchSqlBuilder.PageInfo(pageIndex, pageSize);
     return(search);
 }
 /// <summary>
 /// 构建常规查询
 /// </summary>
 /// <param name="search"></param>
 /// <param name="act">查询委托</param>
 /// <returns></returns>
 public static SearchSqlBuilder Create(this SearchSqlBuilder search, Action <SqlBuilder> act)
 {
     search.QueryConditionAct = act;
     return(search);
 }
Esempio n. 5
0
        /// <summary>
        /// 通过指定条件获取单一实体
        /// 多于一条则报错,不确定有且仅有一条时请使用 First
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="search">查询条件</param>
        /// <returns></returns>
        public TEntity Single <TEntity>(SearchSqlBuilder search)
        {
            var _sqlTmpl = search.Build <TEntity>(this.DataContext);

            return(DataContext.SingleOrDefault <TEntity>(_sqlTmpl));
        }