/// <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 != null && QueryFields.Any()) { var fieldList = new List <string>(); QueryFields.ToList().ForEach(queryField => { fieldList.Add(queryField.AsFieldAndParameter()); }); groupList.Add(fieldList.Join(separator)); } if (QueryGroups != null && QueryGroups.Any()) { var fieldList = new List <string>(); QueryGroups.ToList().ForEach(queryGroup => { 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> /// <returns>A stringified formatted-text of the current instance.</returns> public string GetString() { var groupList = new List <string>(); var conjunction = GetConjunctionText(); if (QueryFields != null && QueryFields.Any()) { var fieldList = new List <string>(); QueryFields.ToList().ForEach(queryField => { fieldList.Add(queryField.AsFieldAndParameter()); }); groupList.Add(fieldList.Join($" {conjunction} ")); } if (QueryGroups != null && QueryGroups.Any()) { var fieldList = new List <string>(); QueryGroups.ToList().ForEach(queryGroup => { fieldList.Add(queryGroup.GetString()); }); groupList.Add(fieldList.Join($" {conjunction} ")); } return($"({groupList.Join($" {conjunction} ")})"); }
/// <summary> /// Reset the <see cref="QueryGroup"/> back to its default state (as is newly instantiated). /// </summary> public void Reset() { // Rest all fields if (QueryFields?.Any() == true) { foreach (var field in QueryFields) { field.Reset(); } } // Rest all groups if (QueryGroups?.Any() == true) { foreach (var group in QueryGroups) { group.Reset(); } } // Reset the attribute m_conjuctionTextAttribute = null; m_isFixed = false; // Reset the hash code m_hashCode = null; }
/// <summary> /// Reset all the query fields. /// </summary> private void ResetQueryFields() { if (QueryFields?.Any() != true) { return; } foreach (var field in QueryFields) { field.Reset(); } }