hi
I need to create a custom result type progrmatically.Following is the code
ResultItemType resultitemType = new ResultItemType(owner); resultitemType.DisplayTemplateUrl = AppConstants.SearchResultTypeNames.SearchResultTypeDisplayTemplate.NewsResultDisplayTemplate; resultitemType.Name = "SE1"; PropertyRuleOperator ruleOperator = new PropertyRuleOperator("Equal", "testing description", "=", false, true, true); rule.PropertyName = AppConstants.SearchManagedProperties.ContentTypeId; rule.PropertyValues.Add(AppConstants.ContnetTypeNamesAndId.CTNewsId); rule.PropertyOperator = ruleOperator; resultitemType.Rules = new PropertyRuleCollection(); resultitemType.Rules.Add(rule); resultitemType.DisplayProperties = string.Empty; resultitemType.SourceID = new Guid();
Here resultytpe works fine till I don't add my custom propertyruleoperator but as soon as I add the propertyruleoperator in result type it throws error.
PropertyRuleOperator ruleOperator = new PropertyRuleOperator("Equal", "testing description", "=", false, true, true);
var item2 = resultItemCollection.FirstOrDefault(x => string.Equals(x.Name, "SE2", StringComparison.OrdinalIgnoreCase)); //resultitemcollection is the collectionof all resulttypes item2.Rules.PropertyRules[0].PropertyOperator// using this operator from another source
One more thing when I use propertyruleoperator from any other existing result source then it works fine.
Why is this issue occuring?Can't we create our own propertyruleoperator object ? propertyruleoperator class has hidden operators defined so do we need to go for reflection and use this.