public SqlToken GenerateSqlToken(SelectCommandContext sqlCommandContext) { var result = new OrderByToken(GenerateOrderByIndex(sqlCommandContext)); foreach (var orderByItem in sqlCommandContext.GetOrderByContext().GetItems()) { string columnLabel; if (orderByItem.GetSegment() is ColumnOrderByItemSegment columnOrderByItemSegment) { var quoteCharacterEnum = columnOrderByItemSegment.GetColumn().GetIdentifier().GetQuoteCharacter(); QuoteCharacter quoteCharacter = QuoteCharacter.Get(quoteCharacterEnum); columnLabel = quoteCharacter.GetStartDelimiter() + columnOrderByItemSegment.GetText() + quoteCharacter.GetEndDelimiter(); } else if (orderByItem.GetSegment() is ExpressionOrderByItemSegment expressionOrderByItemSegment) { columnLabel = expressionOrderByItemSegment.GetText(); } else { columnLabel = $"{orderByItem.GetIndex()}"; // String.valueOf(each.getIndex()); } result.ColumnLabels.Add(columnLabel); result.OrderDirections.Add(orderByItem.GetSegment().GetOrderDirection()); } return(result); }
public string ToString(RouteUnit routeUnit) { String actualTableName = GetLogicAndActualTables(routeUnit)[identifier.GetValue().ToLower()]; actualTableName = null == actualTableName?identifier.GetValue().ToLower() : actualTableName; var quoteCharacterEnum = identifier.GetQuoteCharacter(); return($"{QuoteCharacter.Get(quoteCharacterEnum).GetStartDelimiter()}{actualTableName}{QuoteCharacter.Get(quoteCharacterEnum).GetEndDelimiter()}"); }
public string ToString(RouteUnit routeUnit) { StringBuilder result = new StringBuilder(); var quoteCharacterEnum = _identifier.GetQuoteCharacter(); var quoteCharacter = QuoteCharacter.Get(quoteCharacterEnum); result.Append(quoteCharacter.GetStartDelimiter()).Append(_identifier.GetValue()); IDictionary <string, string> logicAndActualTables = GetLogicAndActualTables(routeUnit); if (logicAndActualTables.Any()) { result.Append("_").Append(logicAndActualTables.Values.FirstOrDefault()); } result.Append(quoteCharacter.GetEndDelimiter()); return(result.ToString()); }