Exemplo n.º 1
0
        public void GetQuery(IHqlQuery query, QueryRecord queryRecord)
        {
            var availableFilters = DescribeFilters().ToList();

            foreach (var group in queryRecord.FilterGroups)
            {
                foreach (var filter in group.Filters)
                {
                    var filterContext = new FilterContext()
                    {
                        Query = query,
                        State = JsonConvert.DeserializeObject(filter.State)
                    };

                    string category = filter.Category;
                    string property = filter.PropertyName;

                    var descriptor = availableFilters.FirstOrDefault(x => x.Category == category && x.Property == property);

                    if (descriptor == null)
                    {
                        continue;
                    }

                    descriptor.Filter(filterContext);
                }
            }
        }
Exemplo n.º 2
0
 public void ApplyFilter(FilterContext context, PropertyInfo property)
 {
     var predicate = _filterCoordinator.Filter(property.PropertyType, property.Name, context.State);
     Action<IAliasFactory> alias = x => x.Named(property.DeclaringType.Name);
     context.Query = context.Query.Where(alias, predicate);
 }