public static IQueryable <JGN_Badges_LevelAssociates> processOptionalConditions(IQueryable <JGN_Badges_LevelAssociates> collectionQuery, LevelAssociateEntity query) { if (query.order != "") { collectionQuery = (IQueryable <JGN_Badges_LevelAssociates>)collectionQuery.Sort(query.order); } // validation check (if not set, it will return zero records that will make it difficult to debug the code) if (query.pagesize == 0) { query.pagesize = 18; } // 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); }
private static int CountRecords(ApplicationDbContext context, LevelAssociateEntity entity) { return(context.JGN_Badges_LevelAssociates.Where(returnWhereClause(entity)).Count()); }
public static Task <List <JGN_Badges_LevelAssociates> > Load(ApplicationDbContext context, LevelAssociateEntity entity) { var collectionQuery = context.JGN_Badges_LevelAssociates.Where(returnWhereClause(entity)); collectionQuery = processOptionalConditions(collectionQuery, entity); return(LoadCompleteList(collectionQuery)); }
public static int Count(ApplicationDbContext context, LevelAssociateEntity entity) { return(CountRecords(context, entity)); }
private static System.Linq.Expressions.Expression <Func <JGN_Badges_LevelAssociates, bool> > returnWhereClause(LevelAssociateEntity entity) { var where_clause = PredicateBuilder.New <JGN_Badges_LevelAssociates>(true); if (entity.rewardid > 0) { where_clause = where_clause.And(p => p.rewardid == entity.rewardid); } if (entity.levelid > 0) { where_clause = where_clause.And(p => p.levelid == entity.levelid); } if (entity.id > 0) { where_clause = where_clause.And(p => p.id == entity.id); } return(where_clause); }