(You can attach a screenshot using the paperclip icon on the right?)
A predicate is sometimes a nested structure, expressions which have expressions as arguments. To obtain elements from a predicate you can traverse it. Below I'll give you the sourcecode of the PredicateFinder which is an internal type of the framework but which illustrates what you can do
internal class PredicateFinder : QueryApiObjectTraverser
{
#region Class Member Declarations
private List<IPredicate> _foundPredicates;
private PredicateType _predicateTypeToFind;
#endregion
internal PredicateFinder(bool traverseSetPredicateInnerSetElements = false) : this(PredicateType.Undefined, traverseSetPredicateInnerSetElements)
{
}
internal PredicateFinder(PredicateType predicateTypeToFind, bool traverseSetPredicateInnerSetElements = false)
: base()
{
this.TraverseSetPredicateInnerSetElements = traverseSetPredicateInnerSetElements;
_foundPredicates = new List<IPredicate>();
_predicateTypeToFind = predicateTypeToFind;
}
public override void Traverse(IPredicate objectToTraverse)
{
if(objectToTraverse == null)
{
return;
}
if((_predicateTypeToFind==PredicateType.Undefined && objectToTraverse.InstanceType != (int)PredicateType.PredicateExpression) ||
objectToTraverse.InstanceType == (int)_predicateTypeToFind)
{
_foundPredicates.Add(objectToTraverse);
}
base.Traverse(objectToTraverse);
}
#region Class Property Declarations
internal List<IPredicate> FoundPredicates
{
get { return _foundPredicates; }
}
#endregion
}
Use it by calling Traverse() and passing in your IPredicate object.
obviously you want to do different things, like pull out information from the predicates for logging. So the IPredicate objects you run into have an instance type. You can use that to cast the IPredicate to a dedicated class like FieldCompareValuePredicate and use the values on that for your log string.
An alternative could be to generate the IPredicate to XML, by calling IPredicate.WriteXml(xmlwriter).
Another alternative would be to set its DatabaseSpecificCreator property to an instance of SqlServerSpecificCreator and call ToQueryText(). It might be this property is already set btw, if it's used in a query that was generated, so in that case you can just call ToQueryText() and you get the full SQL fragment for the predicate (with parameters, so you have to write these out manually).