public static IQueryable <AgreegationSubVariable> ApplyFiltering(this IQueryable <AgreegationSubVariable> query, AgreegationSubVariableQuery queryObj) { if (queryObj.VariableId.HasValue) { query = query.Where(v => v.VariableId == queryObj.VariableId.Value); } return(query); }
public async Task <QueryResult <AgreegationSubVariable> > GetAgreegationSubVariablesAsync(AgreegationSubVariableQuery queryObj) { var result = new QueryResult <AgreegationSubVariable>(); var query = context.AgreegationSubVariables .AsQueryable(); query = query.ApplyFiltering(queryObj); result.TotalItems = await query.CountAsync(); query = query.ApplyPaging(queryObj); result.Items = await query.ToListAsync(); return(result); }