<commit_before>namespace EntityFramework.Filters
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Core.Common.CommandTrees;
    using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
    using System.Data.Entity.Core.Metadata.Edm;
    using System.Data.Entity.Core.Objects;
    using System.Data.Entity.Infrastructure;
    using System.Linq;
    using System.Reflection;

    public class FilterQueryVisitor : DefaultExpressionVisitor
    {
        private readonly DbContext _contextForInterception;
        private readonly ObjectContext _objectContext;

        public FilterQueryVisitor(DbContext contextForInterception)
        {
            _contextForInterception = contextForInterception;
            _objectContext = ((IObjectContextAdapter)contextForInterception).ObjectContext;
        }

        public override DbExpression Visit(DbScanExpression expression)
        {
            // a bit harder to get the metadata in CSpace
            var item = expression.Target.ElementType.MetadataProperties.First(p => p.Name == "Configuration");

            // using reflection to get the Annotations property as EntityTtypeConfiguration is an internal class in EF
            Dictionary<string, object> annotations = new Dictionary<string, object>();
            var value = item.Value;
            var propertyInfo = value.GetType().GetProperty("Annotations");
            if (propertyInfo != null)
            {
                annotations = (Dictionary<string, object>) propertyInfo.GetValue(value, null);
            }

            if (!annotations.Any())
            {
                return base.Visit(expression);
            }

            DbExpression current = expression;
            foreach (var globalFilter in annotations.Where(a => a.Key.StartsWith("globalFilter")))
            {
                var convention = (FilterDefinition)globalFilter.Value;

                Filter filterConfig;

                string filterName = globalFilter.Key.Split(new[] { "globalFilter_" }, StringSplitOptions.None)[1];<commit_msg>Skip FilterQueryVisitor when can't find config metadata<commit_after>namespace EntityFramework.Filters
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Core.Common.CommandTrees;
    using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
    using System.Data.Entity.Core.Metadata.Edm;
    using System.Data.Entity.Core.Objects;
    using System.Data.Entity.Infrastructure;
    using System.Linq;
    using System.Reflection;

    public class FilterQueryVisitor : DefaultExpressionVisitor
    {
        private readonly DbContext _contextForInterception;
        private readonly ObjectContext _objectContext;

        public FilterQueryVisitor(DbContext contextForInterception)
        {
            _contextForInterception = contextForInterception;
            _objectContext = ((IObjectContextAdapter)contextForInterception).ObjectContext;
        }

        public override DbExpression Visit(DbScanExpression expression)
        {
            // a bit harder to get the metadata in CSpace
            var item = expression.Target.ElementType.MetadataProperties.FirstOrDefault(p => p.Name == "Configuration");
            
            if(item == null)
            {
                return base.Visit(expression);
            }

            // using reflection to get the Annotations property as EntityTtypeConfiguration is an internal class in EF
            Dictionary<string, object> annotations = new Dictionary<string, object>();
            var value = item.Value;
            var propertyInfo = value.GetType().GetProperty("Annotations");
            if (propertyInfo != null)
            {
                annotations = (Dictionary<string, object>) propertyInfo.GetValue(value, null);
            }

            if (!annotations.Any())
            {
                return base.Visit(expression);
            }

            DbExpression current = expression;
            foreach (var globalFilter in annotations.Where(a => a.Key.StartsWith("globalFilter")))
            {
                var convention = (FilterDefinition)globalFilter.Value;

                Filter filterConfig;

                string filterName = globalFilter.Key.Split(new[] { "globalFilter_" }, StringSplitOptions.None)[1];
{'fraction_non_alphanumeric': 0.08095238095238096, 'fraction_numerical': 0.00045351473922902497, 'mean_word_length': 2.473228346456693, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '972492', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1008, 'n_words': 245}