Example #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MailKit.Search.OrderBy"/> class.
		/// </summary>
		/// <param name="type">The field to sort by.</param>
		/// <param name="order">The sort order.</param>
		/// <exception cref="System.ArgumentOutOfRangeException">
		/// <paramref name="order"/> cannot be <see cref="SortOrder.None"/>.
		/// </exception>
		public OrderBy (OrderByType type, SortOrder order)
		{
			if (order == SortOrder.None)
				throw new ArgumentOutOfRangeException ("order");

			Order = order;
			Type = type;
		}
 private static string OrderByType2String(OrderByType type) {
   switch (type) {
     case OrderByType.Ascending:
       return "ASC";
     case OrderByType.Descending:
       return "DESC";
     default:
       throw new ApplicationException("Uncovered order by type: " + type);
   }
 }
Example #3
0
    public static string GetVideosByTagNOTIMPLEMENTED(OrderByType orderByType, string Tag)
    {
        string ListerHTML = string.Empty;

        Video.GetVideosByTag(orderByType, Tag);

        //string CacheKey = "VideoByTag";

        //ListerHTML = (string)System.Web.HttpContext.Current.Cache[CacheKey];

        //if (System.Web.HttpContext.Current.Cache.Get(CacheKey) == null)
        //{
        //    List<Category> Categories = Category.GetAllCategory();

        //    for (int i = 1; i < Categories.Count; i++)
        //    {
        //        ListerHTML += "<li><a href='video.aspx?cat=" + Categories[i].CategoryID + "'>" + Categories[i].Name + "</a></li>";
        //    }

        //    System.Web.HttpContext.Current.Cache.Insert(CacheKey, ListerHTML, null, DateTime.Now.AddMinutes(60), System.Web.Caching.Cache.NoSlidingExpiration);
        //}

        return ListerHTML;
    }
Example #4
0
 /// <summary>
 /// 获取操作日志分页list
 /// </summary>
 /// <param name="whereExpression">筛选条件</param>
 /// <param name="page">第几页</param>
 /// <param name="limit">每页条数</param>
 /// <param name="total">筛选后总数据条数</param>
 /// <param name="orderByExpression">排序字段</param>
 /// <param name="orderByType">排序方式;Default:OrderByType.Asc</param>
 /// <returns></returns>
 public IList <LogEvent> GetEventPageList(Expression <Func <LogEvent, bool> > whereExpression, int page, int limit, ref int total, Expression <Func <LogEvent, object> > orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
 {
     if (whereExpression == null)
     {
         return(Db.Queryable <LogEvent>().OrderBy(orderByExpression, orderByType).ToPageList(page, limit, ref total));
     }
     return(Db.Queryable <LogEvent>().Where(whereExpression).OrderBy(orderByExpression, orderByType).ToPageList(page, limit, ref total));
 }
Example #5
0
 /// <summary>
 /// 根据指定列 In 查询
 /// </summary>
 /// <typeparam name="S">指定列的类型</typeparam>
 /// <param name="column">指定列</param>
 /// <param name="list">指定列 In 操作 的结果集</param>
 /// <returns></returns>
 public async Task <List <T> > GetByIn <S>(Expression <Func <T, object> > column, List <S> list, bool isOrderBy = false, Expression <Func <T, object> > orderBy = null, OrderByType orderByType = OrderByType.Asc)
 {
     return(await _dbBase.Queryable <T>().Where(ConModels).In <S>(column, list).OrderByIF(isOrderBy, orderBy, orderByType).ToListAsync());
 }
Example #6
0
 /// <summary>
 /// Orders the rows in the query.
 /// </summary>
 /// <param name="value">The condition to order by.</param>
 /// <param name="order">The direction to order the results.</param>
 /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="value"/> is null or empty.</exception>
 /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
 public virtual IQueryResultFilter OrderBy(string value, OrderByType order = OrderByType.Ascending)
 {
     return CreateResultFilter(this).OrderBy(value, order);
 }
Example #7
0
        public async override Task <List <Atendimento> > GetAllAsync(Expression <Func <Atendimento, object> > expression = null, OrderByType orderByType = OrderByType.NaoClassificado)
        {
            expression  = (expression == null) ? (a => a.DataHoraChegada) : expression;
            orderByType = orderByType == OrderByType.NaoClassificado ? OrderByType.Descendente : orderByType;

            using (var context = DatabaseContext.GetContext(dbPath))
            {
                var query = PrepareDataToGetlAll(context, expression, orderByType);
                query = query.Include(nameof(Atendimento.Cliente));
                return(await query.ToListAsync());
            }
        }
Example #8
0
 /// <summary>
 ///   复制到数组并制定起始索引
 /// </summary>
 /// <param name = "array">数组</param>
 /// <param name = "index">起始索引</param>
 public void CopyTo(OrderByType[] array, int index)
 {
     innerValues.CopyTo(array, index);
 }
 public OrderByExpression(Expression source, Expression fieldName, OrderByType orderType)
 {
     Source = source;
     FieldName = fieldName;
     OrderType = orderType;
 }
Example #10
0
 /// <summary>
 ///     根据条件查询分页数据
 /// </summary>
 /// <param name="predicate">判断集合</param>
 /// <param name="orderByType">排序方式</param>
 /// <param name="pageIndex">当前页面索引</param>
 /// <param name="pageSize">分布大小</param>
 /// <param name="orderByExpression"></param>
 /// <returns></returns>
 public async Task <IPageList <T> > QueryPageAsync(Expression <Func <T, bool> > predicate,
                                                   Expression <Func <T, object> > orderByExpression, OrderByType orderByType, int pageIndex = 1,
                                                   int pageSize = 20)
 {
     return(await BaseDal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize));
 }
Example #11
0
 /// <summary>
 /// Orders the rows in the query based on a single column.
 /// </summary>
 /// <param name="columnName">The name of the column to order by.</param>
 /// <param name="order">The direction to order the results.</param>
 /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
 /// <exception cref="InvalidQueryException"><paramref name="columnName"/> is not a valid column name.</exception>
 /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
 public IQueryResultFilter OrderByColumn(string columnName, OrderByType order)
 {
     return CreateQueryResultFilter(this).OrderByColumn(columnName, order);
 }
Example #12
0
 /// <summary>
 ///     根据条件查询数据
 /// </summary>
 /// <param name="predicate">条件表达式树</param>
 /// <param name="orderByPredicate">排序字段</param>
 /// <param name="orderByType">排序顺序</param>
 /// <returns></returns>
 public async Task <T> QueryByClauseAsync(Expression <Func <T, bool> > predicate,
                                          Expression <Func <T, object> > orderByPredicate, OrderByType orderByType)
 {
     return(await BaseDal.QueryByClauseAsync(predicate, orderByPredicate, orderByType));
 }
Example #13
0
 /// <summary>
 ///     根据条件查询分页数据
 /// </summary>
 /// <param name="predicate">判断集合</param>
 /// <param name="orderByType">排序方式</param>
 /// <param name="pageIndex">当前页面索引</param>
 /// <param name="pageSize">分布大小</param>
 /// <param name="orderByExpression"></param>
 /// <returns></returns>
 public IPageList <T> QueryPage(Expression <Func <T, bool> > predicate,
                                Expression <Func <T, object> > orderByExpression, OrderByType orderByType, int pageIndex = 1,
                                int pageSize = 20)
 {
     return(BaseDal.QueryPage(predicate, orderByExpression, orderByType, pageIndex, pageSize));
 }
Example #14
0
 /// <summary>
 ///     根据条件查询一定数量数据
 /// </summary>
 /// <param name="predicate">条件表达式树</param>
 /// <param name="take">获取数量</param>
 /// <param name="orderByPredicate">排序字段</param>
 /// <param name="orderByType">排序顺序</param>
 /// <returns></returns>
 public List <T> QueryListByClause(Expression <Func <T, bool> > predicate, int take,
                                   Expression <Func <T, object> > orderByPredicate, OrderByType orderByType)
 {
     return(BaseDal.QueryListByClause(predicate, take, orderByPredicate, orderByType));
 }
Example #15
0
 /// <summary>
 /// 根据表达式查询分页并排序
 /// </summary>
 /// <param name="whereExpression">it</param>
 /// <param name="pageModel"></param>
 /// <param name="orderByExpression">it=>it.id或者it=>new{it.id,it.name}</param>
 /// <param name="orderByType">OrderByType.Desc</param>
 /// <returns></returns>
 public virtual List <T> GetPageList(Expression <Func <T, bool> > whereExpression, PageModel pageModel, Expression <Func <T, object> > orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
 {
     return(CurrentDb.GetPageList(whereExpression, pageModel, orderByExpression, orderByType));
 }
Example #16
0
 public List <T> GetPageList(PageModel page, Expression <Func <T, bool> > whereExpression = null,
                             Expression <Func <T, object> > orderByExpression             = null, OrderByType orderByType = OrderByType.Asc)
 {
     return(DbContext.GetPageList <T>(page, whereExpression, orderByExpression, orderByType));
 }
Example #17
0
 /// <summary>
 /// 单个条件 根据 isWhere 判断 是否使用此条件进行查询
 /// </summary>
 /// <param name="isWhere">判断是否使用此查询条件的条件</param>
 /// <param name="where">查询条件</param>
 /// <returns></returns>
 public async Task <List <T> > GetByWhereIF(bool isWhere, Expression <Func <T, bool> > where, bool isOrderBy = false, Expression <Func <T, object> > orderBy = null, OrderByType orderByType = OrderByType.Asc)
 {
     return(await _dbBase.Queryable <T>().Where(ConModels).WhereIF(isWhere, where).OrderByIF(isOrderBy, orderBy, orderByType).ToListAsync());
 }
Example #18
0
 /// <summary>
 /// Orders the rows in the query.
 /// </summary>
 /// <param name="value">The condition to order by.</param>
 /// <param name="order">The direction to order the results.</param>
 /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="value"/> is null or empty.</exception>
 /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
 public IQueryResultFilter OrderBy(string value, OrderByType order = OrderByType.Ascending)
 {
     return(CreateQueryResultFilter(this).OrderBy(value, order));
 }
Example #19
0
 /// <summary>
 /// 查询 指定列的值 在 start至end 之间的数据
 /// </summary>
 /// <param name="value">指定类</param>
 /// <param name="start">开始</param>
 /// <param name="end">结束</param>
 /// <returns></returns>
 public async Task <List <T> > GetByBetween(object value, object start, object end, bool isOrderBy = false, Expression <Func <T, object> > orderBy = null, OrderByType orderByType = OrderByType.Asc)
 {
     return(await _dbBase.Queryable <T>().Where(ConModels).Where(it => SqlFunc.Between(value, start, end)).OrderByIF(isOrderBy, orderBy, orderByType).ToListAsync());
 }
Example #20
0
 /// <summary>
 /// Orders the rows in the query based on a single column.
 /// </summary>
 /// <param name="columnName">The name of the column to order by.</param>
 /// <param name="order">The direction to order the results.</param>
 /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
 /// <exception cref="InvalidQueryException"><paramref name="columnName"/> is not a valid column name.</exception>
 /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
 public IQueryResultFilter OrderByColumn(string columnName, OrderByType order = OrderByType.Ascending)
 {
     return(CreateQueryResultFilter(this).OrderByColumn(columnName, order));
 }
 public UnionExpression OrderBy(SqlColumn column, OrderByType type) {
   var clone = Clone();
   clone.myOrderBy.Add(new OrderByStatement {Column = column, Type = type});
   return clone;
 }
Example #22
0
 public ISugarQueryable <APIList> LoadEntities(Expression <Func <APIList, bool> > whereLambda, Expression <Func <APIList, object> > orderExpression, OrderByType type = OrderByType.Asc)
 {
     if (null == orderExpression)
     {
         throw new Exception("排序表达式不能为空");
     }
     return(db.Queryable <APIList>().WhereIF(whereLambda != null, whereLambda).OrderBy(orderExpression, type));
 }
Example #23
0
 /// <summary>
 ///   增加排序字段
 /// </summary>
 /// <param name = "fieldName">字段名</param>
 /// <param name = "orderByType">排序类型</param>
 public virtual void Add(string fieldName, OrderByType orderByType)
 {
     if (InnerHashtable.Contains(fieldName))
     {
         var index = innerValues.IndexOf((OrderByType) InnerHashtable[fieldName]);
         innerValues[index] = orderByType;
         InnerHashtable[fieldName] = orderByType;
     }
     else
     {
         innerKeys.Add(fieldName);
         InnerHashtable[fieldName] = orderByType;
         innerValues.Add(orderByType);
     }
 }
Example #24
0
 public List <APIList> LoadPageList(Expression <Func <APIList, bool> > whereLambda, Expression <Func <APIList, object> > Orderexpression, OrderByType type, int pageIndex, int pageSize, ref int totalNumber)
 {
     if (null == Orderexpression)
     {
         throw new Exception("排序表达式不能为空");
     }
     return(db.Queryable <APIList>().WhereIF(whereLambda != null, whereLambda).OrderBy(Orderexpression, type).ToPageList(pageIndex, pageSize, ref totalNumber));
 }
Example #25
0
 OrderBy(OrderByType type, SortOrder order)
 {
     Order = order;
     Type = type;
 }
Example #26
0
        /// <summary>
        /// 排序
        /// </summary>
        /// <typeparam name="T">表实体类型</typeparam>
        /// <typeparam name="T2">表实体类型</typeparam>
        /// <param name="queryable">查询对象</param>
        /// <param name="expression">例如 (s1,s2)=>s1.id,相当于 order by s1.id</param>
        /// <param name="type">排序类型</param>
        /// <returns>Queryable</returns>
        public static Queryable <T> OrderBy <T, T2>(this Queryable <T> queryable, Expression <Func <T, T2, object> > expression, OrderByType type = OrderByType.asc)
        {
            ResolveExpress re    = new ResolveExpress();
            var            field = re.GetExpressionRightFieldByNT(expression, queryable.DB);
            var            pre   = queryable.OrderByValue.IsValuable() ? "," : "";

            queryable.OrderByValue += pre + field + " " + type.ToString().ToUpper();
            return(queryable);
        }
Example #27
0
    public string GetTopVideos(OrderByType TabType)
    {
        string CacheKey = "TopVideo" + TabType;

        Videos = (List<Video>)System.Web.HttpContext.Current.Cache[CacheKey];

        if (System.Web.HttpContext.Current.Cache.Get(CacheKey) == null)
        {
            Videos = Video.GetTop100Videos((OrderByType)TabType);
            System.Web.HttpContext.Current.Cache.Insert(CacheKey, Videos, null, DateTime.Now.AddSeconds(30.00), System.Web.Caching.Cache.NoSlidingExpiration);
        }

        StringBuilder sbHTMLList = new StringBuilder();

        for (int i = 0; i < 7; i++)
        {
            if (Videos.Count <= i)
            {
                break;
            }
            StringBuilder sbHTMLItem = new StringBuilder();

            object[] parameters = new object[15];

            parameters[0] = ParallelServer.Get() + Videos[i].ThumbnailResourceFile.FullyQualifiedURL;
            parameters[1] = Videos[i].TimeAgo;
            parameters[2] = Videos[i].Title;
            parameters[3] = Videos[i].Description;
            parameters[4] = Videos[i].NumberOfViews;
            parameters[5] = Videos[i].NumberOfComments;
            parameters[6] = Videos[i].Member.NickName;
            parameters[7] = Videos[i].Category;
            parameters[8] = Videos[i].WebVideoID;
            parameters[9] = Videos[i].TotalVoteScore;
            parameters[10] = Videos[i].Member.WebMemberID;
            parameters[11] = Videos[i].FormattedTags();
            parameters[12] = NCache.GetCategoryName(Videos[i].Category);
            parameters[13] = Videos[i].Category;
            parameters[14] = RegexPatterns.FormatStringForURL(Videos[i].Title);

            string HTMLItem = @"<li><div class='vid_thumb'>
                                    <a href='/video/{14}/{8}/'><img src='{0}' alt='{2}' width='124' height='91' />

                                {1}
                                </div>
                                <div class='vid_info'>
                                    <h3>
                                        <a href='/video/{14}/{8}'>
                                            {2}</a></h3>
                                    <div class='vote vote_condensed'><span class='vote_count'>{9}</span></div>
                                        {3}</p>
                                    <p class='metadata'>
                                        Views: {4} Comments: {5}<br />
                                        Category: <a href='video.aspx?cat={13}'>{12}</a><br />
                                        Tags: {11}<br />
                                        From: <a href='/users/{6}'>{6}</a></p>
                                </div>
                            </li>";


                sbHTMLItem.AppendFormat(HTMLItem, parameters);
                sbHTMLList.Append(sbHTMLItem.ToString());
        }

        return sbHTMLList.ToString();
    }
Example #28
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="workId"> (optional)</param>
 /// <param name="order"> (optional)</param>
 /// <param name="page"> (optional)</param>
 /// <returns>List&lt;QComment&gt;</returns>
 public List <QComment> GetByWork(string workId = default(string), OrderByType order = default(OrderByType), int?page = default(int?))
 {
     Org.OpenAPITools.Client.ApiResponse <List <QComment> > localVarResponse = GetByWorkWithHttpInfo(workId, order, page);
     return(localVarResponse.Data);
 }
Example #29
0
 public ISugarQueryable <T> OrderBy <T2>(System.Linq.Expressions.Expression <Func <T, T2, object> > expression, OrderByType type = OrderByType.Asc)
 {
     this.QueryableCore = ((Queryable <T>) this.QueryableCore).OrderBy <T2>(expression, (OracleSugar.OrderByType)(int) type);
     return(this);
 }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="workId"> (optional)</param>
        /// <param name="order"> (optional)</param>
        /// <param name="page"> (optional)</param>
        /// <returns>ApiResponse of List&lt;QComment&gt;</returns>
        public Org.OpenAPITools.Client.ApiResponse <List <QComment> > GetByWorkWithHttpInfo(string workId = default(string), OrderByType order = default(OrderByType), int?page = default(int?))
        {
            Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "text/plain",
                "application/json",
                "text/json"
            };

            var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes);

            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);

            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            if (workId != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "workId", workId));
            }
            if (order != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "order", order));
            }
            if (page != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "page", page));
            }


            // make the HTTP request
            var localVarResponse = this.Client.Get <List <QComment> >("/api/comments/by-work", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetByWork", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Example #31
0
 /// <summary>
 /// 排序
 /// </summary>
 /// <typeparam name="T2">表实体类型</typeparam>
 /// <param name="expression">例如 (s1,s2)=>s1.id,相当于 order by s1.id</param>
 /// <param name="type">排序类型</param>
 /// <returns></returns>
 public Queryable <T> OrderBy <T2>(Expression <Func <T, T2, object> > expression, OrderByType type = OrderByType.Asc)
 {
     return(this.OrderBy <T, T2>(expression, type));
 }
Example #32
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="workId"> (optional)</param>
        /// <param name="order"> (optional)</param>
        /// <param name="page"> (optional)</param>
        /// <returns>Task of List&lt;QComment&gt;</returns>
        public async System.Threading.Tasks.Task <List <QComment> > GetByWorkAsync(string workId = default(string), OrderByType order = default(OrderByType), int?page = default(int?))
        {
            Org.OpenAPITools.Client.ApiResponse <List <QComment> > localVarResponse = await GetByWorkAsyncWithHttpInfo(workId, order, page);

            return(localVarResponse.Data);
        }
Example #33
0
 /// <summary>
 /// 根据指定列 Not In (!Contain)查询
 /// </summary>
 /// <typeparam name="S">指定列类型</typeparam>
 /// <param name="list">Not In的结果集</param>
 /// <param name="field">指定列</param>
 /// <returns></returns>
 public async Task <List <T> > GetByNotIn <S>(List <S> list, object field, bool isOrderBy = false, Expression <Func <T, object> > orderBy = null, OrderByType orderByType = OrderByType.Asc)
 {
     return(await _dbBase.Queryable <T>().Where(ConModels).Where(t => !SqlFunc.ContainsArray(list, field)).OrderByIF(isOrderBy, orderBy, orderByType).ToListAsync());
 }
Example #34
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="workId"> (optional)</param>
        /// <param name="order"> (optional)</param>
        /// <param name="page"> (optional)</param>
        /// <returns>Task of ApiResponse (List&lt;QComment&gt;)</returns>
        public async System.Threading.Tasks.Task <Org.OpenAPITools.Client.ApiResponse <List <QComment> > > GetByWorkAsyncWithHttpInfo(string workId = default(string), OrderByType order = default(OrderByType), int?page = default(int?))
        {
            Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "text/plain",
                "application/json",
                "text/json"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            if (workId != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "workId", workId));
            }
            if (order != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "order", order));
            }
            if (page != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "page", page));
            }


            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.GetAsync <List <QComment> >("/api/comments/by-work", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetByWork", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Example #35
0
        /// <summary>
        /// 多个条件 根据 wheres.value  判断是否使用 此 wheres.key 的条件
        /// </summary>
        /// <param name="wheres">查询条件</param>
        /// <returns></returns>
        public async Task <List <T> > GetByWhereIF(Dictionary <Expression <Func <T, bool> >, bool> wheres, bool isOrderBy = false, Expression <Func <T, object> > orderBy = null, OrderByType orderByType = OrderByType.Asc)
        {
            var able = _dbBase.Queryable <T>().Where(ConModels);

            foreach (var item in wheres)
            {
                able.WhereIF(item.Value, item.Key);
            }
            return(await able.OrderByIF(isOrderBy, orderBy, orderByType).ToListAsync());
        }
 public SelectStatement OrderBy(SqlColumn column, OrderByType type) {
   SelectStatement clone = Clone();
   clone.myOrderBy.Add(new OrderByStatement {Column = column, Type = type});
   return clone;
 }
Example #37
0
 /// <summary>
 /// Orders the rows in the query.
 /// </summary>
 /// <param name="value">The condition to order by.</param>
 /// <param name="order">The direction to order the results.</param>
 /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="value"/> is null or empty.</exception>
 /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
 public IQueryResultFilter OrderBy(string value, OrderByType order)
 {
     return CreateQueryResultFilter(this).OrderBy(value, order);
 }
        /// <summary>
        /// Orders the rows in the query.
        /// </summary>
        /// <param name="value">The condition to order by.</param>
        /// <param name="order">The direction to order the results.</param>
        /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is null or empty.</exception>
        /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
        public IQueryResultFilter OrderBy(string value, OrderByType order)
        {
            if (string.IsNullOrEmpty(value))
                throw new ArgumentNullException("value");
            if (!EnumHelper<OrderByType>.IsDefined(order))
                throw new ArgumentException(string.Format("{0} is not a valid OrderByType value.", order), "order");

            _orderBys.Add(new KeyValuePair<string, OrderByType>(value, order));

            return this;
        }
        /// <summary>
        /// 排序
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="sortField"></param>
        /// <param name="orderByType"></param>
        /// <returns></returns>
        public static IOrderedEnumerable <T> ThenBy <T>(this IOrderedEnumerable <T> list, string sortField, OrderByType orderByType)
        {
            var          type = typeof(T);
            PropertyInfo prop = type.GetProperty(sortField);

            Check.Exception(prop == null, "No property '" + sortField + "' in + " + typeof(T).Name + "'");
            if (orderByType == OrderByType.desc)
            {
                return(list.ThenByDescending(it => ConvertField(prop.GetValue(it, null))));
            }
            else
            {
                return(list.ThenBy(it => ConvertField(prop.GetValue(it, null))));
            }
        }
        /// <summary>
        /// Orders the rows in the query based on a single column.
        /// </summary>
        /// <param name="columnName">The name of the column to order by.</param>
        /// <param name="order">The direction to order the results.</param>
        /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
        /// <exception cref="InvalidQueryException"><paramref name="columnName"/> is not a valid column name.</exception>
        /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
        public IQueryResultFilter OrderByColumn(string columnName, OrderByType order)
        {
            if (!EnumHelper<OrderByType>.IsDefined(order))
                throw new ArgumentException(string.Format("{0} is not a valid OrderByType value.", order), "order");

            Settings.IsValidColumnName(columnName, true);

            _orderBys.Add(new KeyValuePair<string, OrderByType>(Settings.EscapeColumn(columnName), order));

            return this;
        }
        /// <summary>
        /// 排序
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="sortField"></param>
        /// <param name="orderByType"></param>
        /// <returns></returns>
        public static IOrderedEnumerable <T> ThenByDataRow <T>(this IOrderedEnumerable <T> list, string sortField, OrderByType orderByType) where T : DataRow
        {
            var          type = typeof(T);
            PropertyInfo prop = type.GetProperty(sortField);

            if (orderByType == OrderByType.desc)
            {
                return(list.ThenByDescending(it => ConvertField(it[sortField])));
            }
            else
            {
                return(list.ThenBy(it => ConvertField(it[sortField])));
            }
        }
Example #42
0
 /// <summary>
 /// 根据条件获得记录列表
 /// </summary>
 /// <param name="skip"></param>
 /// <param name="top"></param>
 /// <param name="user"></param>
 /// <param name="problem"></param>
 /// <param name="contest"></param>
 /// <param name="language"></param>
 /// <param name="status"></param>
 /// <param name="order"></param>
 /// <returns></returns>
 public static List<Record> Select(int skip, int top, string user, string problem, string contest, LanguageType? language, StatusType? status, OrderByType order)
 {
     bool privillege;
     Guid uid;
     if (null == Domain.User.CurrentUser)
     {
         uid = Guid.Empty;
         privillege = false;
     }
     else
     {
         uid = Domain.User.CurrentUser.ID;
         privillege = Domain.User.CurrentUser.IsAdmin;
     }
     using (var db = new CHDB())
     {
         return (from r in db.RecordList(top, skip, user, problem, contest, (int?)status, (int?)language, (int?)order, privillege, uid)
                 select new Record
                 {
                     CodeLength = (int)r.CodeLength,
                     Contest = r.Contest,
                     ExecutedTime = null != r.ExecutedTime ? (TimeSpan?)TimeSpan.FromMilliseconds((int)r.ExecutedTime) : null,
                     ID = (Guid)r.ID,
                     Language = (LanguageType)r.Language,
                     Memory = r.MemoryUsed,
                     Problem = r.Problem,
                     Score = r.Score,
                     Status = (StatusType?)r.Status,
                     SubmitTime = (DateTime)r.SubmitTime,
                     User = r.User
                 }).ToList();
     }
 }
Example #43
0
 /// <summary>
 ///   复制到数组
 /// </summary>
 /// <param name = "array">数组</param>
 public virtual void CopyTo(OrderByType[] array)
 {
     innerValues.CopyTo(array);
 }
Example #44
0
 /// <summary>
 /// 获取分页数据(注意:该函数不可以在事务内使用)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="unqueField">数据库中数据唯一的列(建议:主键GUID)</param>
 /// <param name="sql"></param>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <param name="pageCount"></param>
 /// <param name="orderByField"></param>
 /// <param name="orderByType"></param>
 /// <param name="whereObj">参数 例如: new { id="1",name="张三"}</param>
 /// <returns></returns>
 public List <T> TaskableWithPage <T>(string unqueField, string sql, int pageIndex, int pageSize, ref int pageCount, string orderByField, OrderByType orderByType, object whereObj = null) where T : class
 {
     return(TaskableWithPage <T>(unqueField, sql, pageIndex, pageSize, ref pageCount, new List <OrderByDictionary>()
     {
         new OrderByDictionary()
         {
             OrderByField = orderByField, OrderByType = orderByType
         }
     }, whereObj));
 }
Example #45
0
 /// <summary>
 ///   增加排序字段
 /// </summary>
 /// <param name = "key">排序字段</param>
 /// <param name = "orderByType">排序类型</param>
 public override sealed void Add(string key, OrderByType orderByType)
 {
     lock (syncRoot)
     {
         innerNoC.Add(key, orderByType);
     }
 }
 public OrderByClip(string fieldName, OrderByType orderBy)
 {
     orderByClip.Add(fieldName, orderBy);
 }
Example #47
0
 /// <summary>
 ///   获取排序逻辑
 /// </summary>
 /// <param name = "obt">逻辑类型</param>
 /// <returns>符号</returns>
 public static string GetOrderByType(OrderByType obt)
 {
     return obt == OrderByType.Asc ? "ASC" : "DESC";
 }
 /// <summary>
 /// TODO
 /// </summary>
 /// <param name="field"></param>
 /// <param name="orderBy"></param>
 public OrderByClip(Field field, OrderByType orderBy)
     : this(field.TableFieldName, orderBy)
 {
 }
Example #49
0
 public OrderBy(OrderByType type, Expression expression)
 {
     this.Type = type;
     this.Expression = expression;
 }
Example #50
0
        public List <T> GetPageList <T>(List <IConditionalModel> conditionalList, PageModel page, Expression <Func <T, object> > orderByExpression = null, OrderByType orderByType = OrderByType.Asc) where T : class, new()
        {
            int count  = 0;
            var result = Context.Queryable <T>().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(conditionalList).ToPageList(page.PageIndex, page.PageSize, ref count);

            page.PageCount = count;
            return(result);
        }
 public IJobSearch OrderBy(OrderByType value) {
     _OrderBy = value;
     return this;
 }
Example #52
0
        public static List<Video> GetVideosByCategoryID(OrderByType topVideoType, int CategoryID)
        {
            string OrderByClause = string.Empty;

            switch (topVideoType)
            {
                case OrderByType.Featured:
                    OrderByClause = "Latest";
                    break;
                case OrderByType.Viewed:
                    OrderByClause = "NumberOfViews";
                    break;
                case OrderByType.Discussed:
                    OrderByClause = "NumberOfComments";
                    break;
                case OrderByType.Rated:
                    OrderByClause = "TotalVoteScore";
                    break;
            }

            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbcommand = db.GetStoredProcCommand("HG_GetVideosByCategory");
            db.AddInParameter(dbcommand, "CategoryID", DbType.String, CategoryID);
            db.AddInParameter(dbcommand, "OrderByClause", DbType.String, OrderByClause);

            List<Video> VideosByCategory;

            using (IDataReader dr = db.ExecuteReader(dbcommand))
            {
                VideosByCategory = PopulateObjectWithJoin(dr);
                dr.Close();
            }

            return VideosByCategory;
        }
Example #53
0
 /// <summary>
 /// Orders the rows in the query based on a single column.
 /// </summary>
 /// <param name="columnName">The name of the column to order by.</param>
 /// <param name="order">The direction to order the results.</param>
 /// <returns>The <see cref="IQueryResultFilter"/>.</returns>
 /// <exception cref="InvalidQueryException"><paramref name="columnName"/> is not a valid column name.</exception>
 /// <exception cref="ArgumentException"><paramref name="order"/> is not a defined <see cref="OrderByType"/> enum value.</exception>
 public virtual IQueryResultFilter OrderByColumn(string columnName, OrderByType order = OrderByType.Ascending)
 {
     return CreateResultFilter(this).OrderByColumn(columnName, order);
 }
Example #54
0
 /// <summary>
 /// order ASC or DESC
 /// </summary>
 /// <param name="orderBy"></param>
 /// <param name="order"></param>
 public void OrderBy(string orderBy, OrderByType orderbyType)
 {
     if (orderbyType.HasFlag(OrderByType.ASC))
     {
         this.Order += String.Format(" ORDER BY {0} ASC", orderBy);
     }
     else
     {
         this.Order += String.Format(" ORDER BY {0} DESC", orderBy);
     }
 }