/// <summary> /// Gets the stringified query expression format of the current instance. A formatted string for field-operation-parameter will be /// conjuncted by the value of the <see cref="Conjunction"/> property. /// </summary> /// <returns>A stringified formatted-text of the current instance.</returns> public string GetString() { var groupList = new List <string>(); var conjunction = GetConjunctionText(); var separator = string.Concat(" ", conjunction, " "); if (QueryFields?.Count() > 0) { var fieldList = new List <string>(); foreach (var queryField in QueryFields) { fieldList.Add(queryField.AsFieldAndParameter()); } groupList.Add(fieldList.Join(separator)); } if (QueryGroups?.Count() > 0) { var fieldList = new List <string>(); foreach (var queryGroup in QueryGroups) { fieldList.Add(queryGroup.GetString()); } groupList.Add(fieldList.Join(separator)); } return(IsNot ? string.Concat("NOT (", groupList.Join(conjunction), ")") : string.Concat("(", groupList.Join(separator), ")")); }
/// <summary> /// Gets the stringified query expression format of the current instance. A formatted string for field-operation-parameter will be /// conjuncted by the value of the <see cref="Conjunction"/> property. /// </summary> /// <param name="index">The parameter index for batch operation.</param> /// <returns>A stringified formatted-text of the current instance.</returns> public string GetString(int index) { // Fix first the parameters Fix(); // Variables var groupList = new List <string>(); var conjunction = GetConjunctionText(); var separator = string.Concat(" ", GetConjunctionText(), " "); // Check the instance fields if (QueryFields?.Count() > 0) { var fields = QueryFields .AsList() .Select(qf => qf.AsFieldAndParameter(index)).Join(separator); groupList.Add(fields); } // Check the instance groups if (QueryGroups?.Count() > 0) { var groups = QueryGroups .AsList() .Select(qg => qg.GetString(index)).Join(separator); groupList.Add(groups); } // Return the value return(IsNot ? string.Concat("NOT (", groupList.Join(conjunction), ")") : string.Concat("(", groupList.Join(separator), ")")); }