Ejemplo n.º 1
0
        public QueryResult Query(QueryBase query)
        {
            var q = query as QueryMasterData;
            var userQuery = _context.Clients.AsQueryable();
            var queryResult = new QueryResult();
            if (!string.IsNullOrWhiteSpace(q.Name))
            {
                userQuery = userQuery
                    .Where(s => s.Name.Contains(q.Name) ||
                        s.Code.Contains(q.Description) );
            }

            queryResult.Count = userQuery.Count();
            userQuery = userQuery.OrderBy(s => s.Name);
            if (q.Skip.HasValue && q.Take.HasValue)
                userQuery = userQuery.Skip(q.Skip.Value).Take(q.Take.Value);
            queryResult.Result = userQuery.ToList().OfType<BaseEntity>().ToList();
            return queryResult;
        }
Ejemplo n.º 2
0
 public QueryResult Query(QueryBase query)
 {
     var q = query as QueryReport;
     var myQuery = _context.ReportGroups.AsQueryable();
     var queryResult = new QueryResult();
     if (!string.IsNullOrWhiteSpace(q.Name))
     {
         myQuery = myQuery
             .Where(s => s.Name.Contains(q.Name) ||
                 s.Description.Contains(q.Description) );
     }
     if(q.ClientId.HasValue)
     {
         myQuery = myQuery.Where(s => s.ClientId == q.ClientId);
     }
     queryResult.Count = myQuery.Count();
     myQuery = myQuery.OrderBy(s => s.Name);
     if (q.Skip.HasValue && q.Take.HasValue)
         myQuery = myQuery.Skip(q.Skip.Value).Take(q.Take.Value);
     queryResult.Result = myQuery.ToList().OfType<BaseEntity>().ToList();
     return queryResult;
 }