public static async Task <int> Count(ApplicationDbContext context, BlockIPEntity entity) { return(await context.JGN_BlockIP.Where(returnWhereClause(entity)).CountAsync()); }
private static System.Linq.Expressions.Expression <Func <JGN_BlockIP, bool> > returnWhereClause(BlockIPEntity entity) { var where_clause = PredicateBuilder.New <JGN_BlockIP>(true); if (entity.id > 0) { where_clause = where_clause.And(p => p.id == entity.id); } if (entity.term != "") { where_clause = where_clause.And(p => p.ipaddress.Contains(entity.term)); } return(where_clause); }
public static Task <List <JGN_BlockIP> > LoadItems(ApplicationDbContext context, BlockIPEntity entity) { var collectionQuery = context.JGN_BlockIP.Where(returnWhereClause(entity)); return(LoadCompleteList(processOptionalConditions(collectionQuery, entity))); }
private static IQueryable <JGN_BlockIP> processOptionalConditions(IQueryable <JGN_BlockIP> collectionQuery, BlockIPEntity query) { if (query.order != "") { collectionQuery = (IQueryable <JGN_BlockIP>)collectionQuery.Sort(query.order); } if (query.id == 0) { // skip logic if (query.pagenumber > 1) { collectionQuery = collectionQuery.Skip(query.pagesize * (query.pagenumber - 1)); } // take logic if (!query.loadall) { collectionQuery = collectionQuery.Take(query.pagesize); } } return(collectionQuery); }