Example #1
0
        private void AutoApplyFilters(ReadCommandInfo commandInfo)
        {
            if (_applyFiltersOnClientRead.TryGetValue(commandInfo.DataSource, out List <ApplyFilterWhere> applyFilters))
            {
                commandInfo.Filters ??= Array.Empty <FilterCriteria>();

                var newFilters = applyFilters
                                 .Where(applyFilter => applyFilter.Where == null || applyFilter.Where(commandInfo))
                                 .Where(applyFilter => !commandInfo.Filters.Any(existingFilter => GenericFilterHelper.EqualsSimpleFilter(existingFilter, applyFilter.FilterName)))
                                 .Select(applyFilter => new FilterCriteria {
                    Filter = applyFilter.FilterName
                })
                                 .ToList();

                _logger.Trace(() => "AutoApplyFilters: " + string.Join(", ", newFilters.Select(f => f.Filter)));

                commandInfo.Filters = commandInfo.Filters.Concat(newFilters).ToArray();
            }
        }
        private void AutoApplyFilters(ReadCommandInfo commandInfo)
        {
            List <string> filterNames;

            if (_applyFiltersOnClientRead.TryGetValue(commandInfo.DataSource, out filterNames))
            {
                commandInfo.Filters = commandInfo.Filters ?? new FilterCriteria[] { };

                var newFilters = filterNames
                                 .Where(name => !commandInfo.Filters.Any(existingFilter => GenericFilterHelper.EqualsSimpleFilter(existingFilter, name)))
                                 .Select(name => new FilterCriteria {
                    Filter = name
                })
                                 .ToList();

                _logger.Trace(() => "AutoApplyFilters: " + string.Join(", ", newFilters.Select(f => f.Filter)));

                commandInfo.Filters = commandInfo.Filters.Concat(newFilters).ToArray();
            }
        }