public string BuildSqlString()
        {
            var stringBuilder = new StringBuilder();

            if (string.IsNullOrEmpty(SelectPart) || FromParts.Count == 0)
            {
                throw new InvalidOperationException("A query must have a select part and at least one from part.");
            }

            stringBuilder.Append($"select {SelectPart}");
            stringBuilder.Append($" from {SeparatedStringBuilder.Build(", ", FromParts)}");

            if (WhereParts.Count > 0)
            {
                stringBuilder.Append($" where {SeparatedStringBuilder.Build(" and ", WhereParts)}");
            }

            if (OrderByParts.Count > 0)
            {
                stringBuilder.Append($" order by {SeparatedStringBuilder.Build(", ", OrderByParts)}");
            }

            if (FetchPart != null)
            {
                stringBuilder.Append($" {FetchPart}");
            }

            return(stringBuilder.ToString());
        }
 public void AddOrderByPart(IEnumerable <string> orderings)
 {
     OrderByParts.Insert(0, SeparatedStringBuilder.Build(", ", orderings));
 }