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); }
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); }
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)); }