Пример #1
0
        public bool TryGetEqualFiltersForProperty <TProp>(Expression <Func <TEntity, TProp> > propertySelection, out IReadOnlyList <TProp> equalValues)
        {
            if (propertySelection.Body is MemberExpression memberExpression)
            {
                var key = IndexBuilderVisitor.GetStringFromMemberExpression(memberExpression);

                List <TProp> output = new List <TProp>();
                if (_filters.TryGetValue(key, out var values))
                {
                    foreach (var val in values)
                    {
                        if (val is TProp propVal)
                        {
                            output.Add(propVal);
                        }
                    }
                    equalValues = output;
                    return(true);
                }
                equalValues = null;
                return(false);
            }
            else
            {
                throw new NotSupportedException($"Can only get filters for a property selection");
            }
        }
Пример #2
0
        private IReadOnlyDictionary <string, List <object> > CreateFilters()
        {
            IndexBuilderVisitor indexBuilderVisitor = new IndexBuilderVisitor();

            indexBuilderVisitor.Visit(_whereExpression);
            return(indexBuilderVisitor.Filters);
        }