public CrossQueryPhrase(string fieldName, QueryPhrase queryPhrase) { this.FieldName = fieldName; this.QueryPhrases = new List <QueryPhrase>() { queryPhrase }; }
private IList <QueryPhrase> ToQueryList(QueryPhrase query) { List <QueryPhrase> queries = new List <QueryPhrase> { query }; return(queries); }
private static String BuildPhraseString(QueryPhrase phrase) { String output = null; if (phrase is LogicalQueryPhrase) { LogicalQueryPhrase logicalPhrase = (LogicalQueryPhrase)phrase; List <String> expStrings = new List <string>(); foreach (QueryExpression exp in logicalPhrase.Expressions) { String comparisonOperator = GetComparisonOperatorString(exp.Operator); String valueStr = GetExpressionValueString(exp.Value); String expStr = String.Format("{0}{1}{2}", logicalPhrase.FieldName, comparisonOperator, valueStr); expStrings.Add(expStr); } output = String.Join("||", expStrings); if (expStrings.Count > 1) { output = "(" + output + ")"; } if (logicalPhrase.NegativeCondition) { output = "!" + output; } } else if (phrase is CrossQueryPhrase) { //release={id=5002} CrossQueryPhrase crossPhrase = (CrossQueryPhrase)phrase; String expStr = String.Format("{0}={{{1}}}", crossPhrase.FieldName, BuildPhraseString(crossPhrase.QueryPhrase)); output = expStr; } else { throw new NotImplementedException(); } return(output); }
private static string BuildPhraseString(QueryPhrase phrase) { string output = null; if (phrase is LogicalQueryPhrase) { LogicalQueryPhrase logicalPhrase = (LogicalQueryPhrase)phrase; List <string> expStrings = new List <string>(); foreach (QueryExpression exp in logicalPhrase.Expressions) { string comparisonOperator = GetComparisonOperatorString(exp.Operator); string valueStr = GetExpressionValueString(exp.Value); string expStr = string.Format("{0}{1}{2}", logicalPhrase.FieldName, comparisonOperator, valueStr); expStrings.Add(expStr); } output = string.Join("||", expStrings); if (expStrings.Count > 1) { output = "(" + output + ")"; } } else if (phrase is CrossQueryPhrase) { //release={id=5002} CrossQueryPhrase crossPhrase = (CrossQueryPhrase)phrase; List <String> crossPhraseStrings = new List <String>(); foreach (QueryPhrase tempPhrase in crossPhrase.QueryPhrases) { string phraseString = BuildPhraseString(tempPhrase); crossPhraseStrings.Add(phraseString); } string crossJoin = string.Join(";", crossPhraseStrings); string expStr = string.Format("{0}={{{1}}}", crossPhrase.FieldName, crossJoin); output = expStr; } else if (phrase is NegativeQueryPhrase) { NegativeQueryPhrase negativePhrase = (NegativeQueryPhrase)phrase; string expStr = string.Format("!{0}", BuildPhraseString(negativePhrase.QueryPhrase)); output = expStr; } else if (phrase is InQueryPhrase) { InQueryPhrase inQueryPhrase = (InQueryPhrase)phrase; StringBuilder sb = new StringBuilder("("); sb.Append(inQueryPhrase.FieldName); sb.Append("+IN+"); for (var i = 0; i < inQueryPhrase.Values.Count; i++) { sb.Append(GetExpressionValueString(inQueryPhrase.Values[i])); if (i != inQueryPhrase.Values.Count - 1) { sb.Append(","); } } sb.Append(")"); output = sb.ToString(); } else if (phrase is NullQueryPhrase) { output = "null"; } else { throw new NotImplementedException(); } return(output); }
public CrossQueryPhrase(String fieldName, QueryPhrase queryPhrase) { this.FieldName = fieldName; this.QueryPhrase = queryPhrase; }
public NegativeQueryPhrase(QueryPhrase phrase) { this.QueryPhrase = phrase; }