コード例 #1
0
 /// <summary>
 /// Get site regions.
 /// </summary>
 /// <param name="site"></param>
 /// <returns></returns>
 public static ICollection <SiteClaim> GetRegions(this Site site, EOrderBy orderby = EOrderBy.Id)
 {
     if (orderby == EOrderBy.Name)
     {
         return(site?.SiteClaims?.Where(sc => sc.Type == SiteClaimType.Region).OrderBy(sc => sc.StringValue)?.ToList());
     }
     return(site?.SiteClaims?.Where(s => s.Type == SiteClaimType.Region).OrderBy(sc => sc.Id)?.ToList());
 }
コード例 #2
0
ファイル: SQLBuilder.cs プロジェクト: skiwheelr/KarveCar
        /// <summary>
        /// Crea la cláusula ORDER BY con la condición pasada por params:<para/>
        /// string -> columna por donde ordenar;<para/>
        /// EOrderBy -> tipo de operador ORDER BY (WHITESPACE, ASC, DESC);<para/>
        /// </summary>
        /// <param name="column"></param>
        /// <param name="orderby"></param>
        /// <returns></returns>
        public static string SqlBuilderOrderByOne(string column, EOrderBy orderby)
        {
            string sqlOrderBy = string.Empty;

            sqlOrderBy += column;

            switch (orderby)
            {
            case EOrderBy.WHITESPACE: sqlOrderBy += " ASC, "; break;

            case EOrderBy.ASC: sqlOrderBy += " ASC, "; break;

            case EOrderBy.DESC: sqlOrderBy += " DESC, "; break;

            default: break;
            }

            return(sqlOrderBy.TrimEnd(' ').TrimEnd(',').Replace("  ", " "));
        }
コード例 #3
0
ファイル: SQLBuilder.cs プロジェクト: skiwheelr/KarveCar
        /// <summary>
        /// Crea la cláusula ORDER BY con la condición pasada por params en un Tuple:<para/>
        /// string -> columna por donde ordenar;<para/>
        /// EOrderBy -> tipo de operador ORDER BY (WHITESPACE, ASC, DESC);<para/>
        /// </summary>
        /// <param name="orderByClause"></param>
        /// <returns></returns>
        public static string SqlBuilderOrderByOne(Tuple <string, EOrderBy> orderByClause)
        {
            string sqlOrderBy = string.Empty;

            sqlOrderBy += orderByClause.Item1;

            EOrderBy orderby = orderByClause.Item2;

            switch (orderby)
            {
            case EOrderBy.WHITESPACE: sqlOrderBy += " ASC, "; break;

            case EOrderBy.ASC: sqlOrderBy += " ASC, "; break;

            case EOrderBy.DESC: sqlOrderBy += " DESC, "; break;

            default: break;
            }

            return(sqlOrderBy.TrimEnd(' ').TrimEnd(',').Replace("  ", " "));
        }
コード例 #4
0
 public IEnumerable <TEntity> FindBy(Expression <Func <TEntity, bool> > predicate, EOrderBy orderBy, string orderByPropertyName, IComparer <object> comparer, params Expression <Func <TEntity, object> >[] navigationProperties)
 {
     return(_repository.FindBy(predicate, orderBy, orderByPropertyName, comparer, navigationProperties));
 }
コード例 #5
0
ファイル: RepositoryBase.cs プロジェクト: rafbaptista/UserAPI
        public IQueryable <TEntity> QueryBy(Expression <Func <TEntity, bool> > predicate, EOrderBy orderBy, string orderByPropertyName, IComparer <object> comparer, params Expression <Func <TEntity, object> >[] navigationProperties)
        {
            IQueryable <TEntity> query = IncludeProperties(navigationProperties).AsNoTracking().Where(predicate);

            if (orderBy == EOrderBy.Asc)
            {
                query = query.OrderBy(orderByPropertyName, comparer);
            }
            else
            {
                query = query.OrderByDescending(orderByPropertyName, comparer);
            }

            return(query);
        }