예제 #1
0
파일: Tests.cs 프로젝트: x2find/Where2Find
        public void GivenAnIsExpressionWithSubTypeOfQueriedTypeOnRight_ShouldReturnATermFilterWithTypesFieldAndTypeNameAsValue()
        {
            var client = new Client("", "");

            var filter = client.WhereFilter <TestData>(x => x is TestDataSub);

            filter.Should().BeOfType <TermFilter>();
            var termFilter = (TermFilter)filter;

            termFilter.Value.Equals(TypeHierarchyInterceptor.GetTypeName(typeof(TestDataSub))).Should().BeTrue();
            termFilter.Field.Should().Be(TypeHierarchyInterceptor.TypeHierarchyJsonPropertyName);
        }
예제 #2
0
파일: Tests.cs 프로젝트: x2find/Where2Find
        public void GivenAnIsExpressionWithMemberOnLeftAndSubTypeOfMemberTypeOnRight_ShouldReturnATermFilterWithMembersTypesFieldAndTypeNameAsValue()
        {
            var client = new Client("", "");

            var filter = client.WhereFilter <TestData>(x => x.Another is TestDataSub);

            filter.Should().BeOfType <TermFilter>();
            var termFilter = (TermFilter)filter;

            termFilter.Value.Equals(TypeHierarchyInterceptor.GetTypeName(typeof(TestDataSub))).Should().BeTrue();
            var expectedFieldName = client.GetFieldName <TestData, TestData>(x => x.Another) + "." + TypeHierarchyInterceptor.TypeHierarchyJsonPropertyName;

            termFilter.Field.Should().Be(expectedFieldName);
        }
예제 #3
0
 protected override Expression VisitTypeBinary(TypeBinaryExpression node)
 {
     if (node.NodeType == ExpressionType.TypeIs)
     {
         var fieldName = conventions.FieldNameConvention.GetFieldName(node.Expression);
         if (!string.IsNullOrEmpty(fieldName))
         {
             fieldName += ".";
         }
         fieldName += TypeHierarchyInterceptor.TypeHierarchyJsonPropertyName;
         var typeHiearchyFilter = new TermFilter(fieldName,
                                                 TypeHierarchyInterceptor.GetTypeName(node.TypeOperand));
         AddFilter(typeHiearchyFilter);
     }
     return(base.VisitTypeBinary(node));
 }