/// <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()); }
/// <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(" ", " ")); }
/// <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(" ", " ")); }
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)); }
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); }