public PagedList <Resource> GetAllCachedAsync(PagingParams pagingParams = null, Expression <Func <Resource, bool> > whereExpression = null, Expression <Func <Resource, string> > orderByExpression = null) { PagedList <Resource> resources; if (!_cache.TryGetValue("_RESOURCES", out resources)) { // Key not in cache, so get data. resources = GetAllAsync(pagingParams, whereExpression, orderByExpression); // Set cache options. var cacheEntryOptions = new MemoryCacheEntryOptions() // Keep in cache for this time, reset time if accessed. .SetSlidingExpiration(TimeSpan.FromSeconds(300)); // Save data in cache. _cache.Set("_RESOURCES", resources, cacheEntryOptions); } return(resources); }
public PagedList <TEntity> GetAllAsync(PagingParams pagingParams = null, Expression <Func <TEntity, bool> > whereExpression = null, Expression <Func <TEntity, TOrderBy> > orderByExpression = null) { if (pagingParams == null) { pagingParams = new PagingParams(); } var query = _appDbContext.Set <TEntity>().AsQueryable(); if (orderByExpression != null) { query = query.OrderBy(orderByExpression); } if (whereExpression != null) { query = query.Where(whereExpression); } return(new PagedList <TEntity>(query, pagingParams.PageNumber, pagingParams.PageSize)); }
public PagedList <Project> GetListAsync(PagingParams pagingParams = null, Expression <Func <Project, bool> > whereExpression = null, Expression <Func <Project, string> > orderByExpression = null) { if (pagingParams == null) { pagingParams = new PagingParams(); } var query = _appDbContext.Projects.Include(a => a.ProjectType).Include(a => a.Platform).Include(a => a.Techstack).Include(a => a.ProjectHead).AsQueryable(); //query = query.Where(a => a.ClientContacts.Any(y => y.IsPointOfContact == true)); if (orderByExpression != null) { query = query.OrderBy(orderByExpression); } if (whereExpression != null) { query = query.Where(whereExpression); } return(new PagedList <Project>(query, pagingParams.PageNumber, pagingParams.PageSize)); }
public new PagedList <LocationBillingRole> GetAllAsync(PagingParams pagingParams = null, Expression <Func <LocationBillingRole, bool> > whereExpression = null, Expression <Func <LocationBillingRole, string> > orderByExpression = null) { if (pagingParams == null) { pagingParams = new PagingParams(); } var query = _appDbContext.LocationBillingRoles .Include(a => a.Location) .AsQueryable(); if (orderByExpression != null) { query = query.OrderBy(orderByExpression); } if (whereExpression != null) { query = query.Where(whereExpression); } return(new PagedList <LocationBillingRole>(query, pagingParams.PageNumber, pagingParams.PageSize)); }
public new PagedList <Client> GetAllAsync(PagingParams pagingParams = null, Expression <Func <Client, bool> > whereExpression = null, Expression <Func <Client, string> > orderByExpression = null) { if (pagingParams == null) { pagingParams = new PagingParams(); } var query = _appDbContext.Clients.Include(a => a.ClientContacts).Include(a => a.SalesContact).Include(a => a.Location).Include(a => a.ClientType).AsQueryable(); query = query.Where(a => a.ClientContacts.Any(y => y.IsPointOfContact == true)); if (orderByExpression != null) { query = query.OrderBy(orderByExpression); } if (whereExpression != null) { query = query.Where(whereExpression); } return(new PagedList <Client>(query, pagingParams.PageNumber, pagingParams.PageSize)); }