public List <AccessKey> GetByUsers(int[] userIds, AccessKeyFilter filter = null) { using (var context = new DeviceHiveContext()) { return(context.AccessKeys .Include(e => e.Permissions) .Where(e => userIds.Contains(e.UserID)).Filter(filter).ToList()); } }
public List <AccessKey> GetByUsers(int[] userIds, AccessKeyFilter filter = null) { return(_mongo.AccessKeys.AsQueryable().Where(e => userIds.Contains(e.UserID)).Filter(filter).ToList()); }
public static IQueryable <AccessKey> Filter(this IQueryable <AccessKey> query, AccessKeyFilter filter) { if (filter == null) { return(query); } if (filter.Label != null) { query = query.Where(e => e.Label == filter.Label); } if (filter.LabelPattern != null) { query = query.Where(e => e.Label.Contains(filter.LabelPattern)); } if (filter.Type != null) { query = query.Where(e => e.Type == filter.Type); } if (filter.SortField != AccessKeySortField.None) { switch (filter.SortField) { case AccessKeySortField.ID: query = query.OrderBy(e => e.ID, filter.SortOrder); break; case AccessKeySortField.Label: query = query.OrderBy(e => e.Label, filter.SortOrder); break; } } if (filter.Skip != null) { query = query.Skip(filter.Skip.Value); } if (filter.Take != null) { query = query.Take(filter.Take.Value); } return(query); }
public List <AccessKey> GetByUser(int userId, AccessKeyFilter filter = null) { return(_mongo.AccessKeys.AsQueryable().Where(e => e.UserID == userId).Filter(filter).ToList()); }