/// <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> /// 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), ")")); }
// Equality and comparers /// <summary> /// Returns the hashcode for this <see cref="QueryGroup"/>. /// </summary> /// <returns>The hashcode value.</returns> public override int GetHashCode() { // Make sure to check if this is already taken if (!ReferenceEquals(null, m_hashCode)) { return(m_hashCode.Value); } // Set the default value (should not be nullable for better performance) var hashCode = 0; // Iterates the child query field if (!ReferenceEquals(null, QueryFields)) { QueryFields.ToList().ForEach(queryField => { hashCode += queryField.GetHashCode(); }); } // Iterates the child query groups if (!ReferenceEquals(null, QueryGroups)) { QueryGroups.ToList().ForEach(queryGroup => { hashCode += queryGroup.GetHashCode(); }); } // Set with conjunction hashCode += Conjunction.GetHashCode(); // Set back the hashcode value m_hashCode = hashCode; // Return the actual hash code return(hashCode); }
/// <summary> /// Force to append prefixes on the bound parameter objects. /// </summary> internal void AppendParametersPrefix() { QueryFields? .ToList() .ForEach(queryField => queryField.AppendParameterPrefix()); }