FilterDeviceList() public static method

Filters the device list with the supplied filters
public static FilterDeviceList ( IQueryable list, List filters ) : IQueryable
list IQueryable Devices to filter
filters List Filters to apply
return IQueryable
コード例 #1
0
        public virtual async Task <DeviceListFilterResult> GetDeviceList(DeviceListFilter filter)
        {
            List <DeviceModel> deviceList = await this.GetAllDevicesAsync();

            IQueryable <DeviceModel> filteredDevices = FilterHelper.FilterDeviceList(deviceList.AsQueryable <DeviceModel>(), filter.Clauses);

            IQueryable <DeviceModel> filteredAndSearchedDevices = this.SearchDeviceList(filteredDevices, filter.SearchQuery);

            IQueryable <DeviceModel> sortedDevices = this.SortDeviceList(filteredAndSearchedDevices, filter.SortColumn, filter.SortOrder);

            List <DeviceModel> pagedDeviceList = sortedDevices.Skip(filter.Skip).Take(filter.Take).ToList();

            int filteredCount = filteredAndSearchedDevices.Count();

            return(new DeviceListFilterResult()
            {
                Results = pagedDeviceList,
                TotalDeviceCount = deviceList.Count,
                TotalFilteredCount = filteredCount
            });
        }
コード例 #2
0
        /// <summary>
        /// Searches the DeviceProperties of all devices in the DocumentDB, sorts them and pages based on the provided values
        /// </summary>
        /// <param name="query">Object containing search, filtering, paging, and other info</param>
        /// <returns></returns>
        public async Task <DeviceListQueryResult> GetDeviceList(DeviceListQuery query)
        {
            List <dynamic> deviceList = await GetAllDevicesAsync();

            IQueryable <dynamic> filteredDevices = FilterHelper.FilterDeviceList(deviceList.AsQueryable <dynamic>(), query.Filters);

            IQueryable <dynamic> filteredAndSearchedDevices = SearchDeviceList(filteredDevices, query.SearchQuery);

            IQueryable <dynamic> sortedDevices = SortDeviceList(filteredAndSearchedDevices, query.SortColumn, query.SortOrder);

            List <dynamic> pagedDeviceList = sortedDevices.Skip(query.Skip).Take(query.Take).ToList();

            int filteredCount = filteredAndSearchedDevices.Count();

            return(new DeviceListQueryResult()
            {
                Results = pagedDeviceList,
                TotalDeviceCount = deviceList.Count,
                TotalFilteredCount = filteredCount
            });
        }