Example #1
0
 public QueryResult Query(QueryBase query)
 {
     var accountQuery = _context.Routes.AsQueryable();
     var q = query as QueryMasterData;
     var queryResult = new QueryResult();
     if (!string.IsNullOrWhiteSpace(q.Name))
     {
         accountQuery = accountQuery.Where(s => s.Name.Contains(q.Name));
     }
     queryResult.Count = accountQuery.Count();
     accountQuery = accountQuery.OrderByDescending(s => s.Name);
     if (q.Skip.HasValue && q.Take.HasValue)
         accountQuery = accountQuery.Skip(q.Skip.Value).Take(q.Take.Value);
     queryResult.Result = accountQuery.ToList().OfType<BaseEntity>().ToList();
     return queryResult;
 }
Example #2
0
        public QueryResult Query(QueryBase query)
        {
            var q = query as QueryMasterData;
            var userQuery = _context.Users.AsQueryable();
            var queryResult = new QueryResult();
            if (!string.IsNullOrWhiteSpace(q.Name))
            {
                userQuery = userQuery
                    .Where(s => s.Username.Contains(q.Name) ||
                        s.Fullname.Contains(q.Description) ||
                        s.Email.Contains(q.Description)) ;
            }

            queryResult.Count = userQuery.Count();
            userQuery = userQuery.OrderBy(s => s.Username);
            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;
        }
Example #3
0
 public QueryResult Query(QueryBase query)
 {
     var userQuery = _context.Products.AsQueryable();
     var q = query as QueryMasterData;
     var queryResult = new QueryResult();
     if (!string.IsNullOrWhiteSpace(q.Name))
     {
         userQuery = userQuery.Where(s => s.Name.Contains(q.Name));
     }
     if (q.AccountId != Guid.Empty)
     {
         userQuery = userQuery.Where(s => s.AccountId == q.AccountId);
     }
     queryResult.Count = userQuery.Count();
     userQuery = userQuery.OrderByDescending(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;
 }