/// <summary> /// Translate an ExpandedNavigationSelectItem /// </summary> /// <param name="item">the item to Translate</param> /// <returns>Defined by the implementer</returns> public override string Translate(ExpandedNavigationSelectItem item) { string res = string.Empty; if (item.SelectAndExpand != null) { string selectExpand = this.TranslateSelectExpandClause(item.SelectAndExpand, false); res = string.Concat(res, !string.IsNullOrEmpty(res) && !string.IsNullOrEmpty(selectExpand) ? ";" : null, selectExpand); } if (item.LevelsOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += ExpressionConstants.QueryOptionLevels; res += ExpressionConstants.SymbolEqual; res += NodeToStringBuilder.TranslateLevelsClause(item.LevelsOption); } string currentExpandClause = Translate((ExpandedReferenceSelectItem)item); if (currentExpandClause.EndsWith(ExpressionConstants.SymbolClosedParen, StringComparison.Ordinal)) { return(currentExpandClause.Insert(currentExpandClause.Length - 1, string.IsNullOrEmpty(res) ? string.Empty : ";" + res)); } else { return(string.Concat(currentExpandClause, string.IsNullOrEmpty(res) ? null : string.Concat(ExpressionConstants.SymbolOpenParen, res, ExpressionConstants.SymbolClosedParen))); } }
/// <summary> /// Translate an ExpandedNavigationSelectItem /// </summary> /// <param name="item">the item to Translate</param> /// <returns>Defined by the implementer</returns> public override string Translate(ExpandedNavigationSelectItem item) { NodeToStringBuilder nodeToStringBuilder = new NodeToStringBuilder(); string currentExpandClause = String.Join("/", item.PathToNavigationProperty.WalkWith(PathSegmentToStringTranslator.Instance).ToArray()); string res = string.Empty; if (item.FilterOption != null) { res += "$filter=" + nodeToStringBuilder.TranslateFilterClause(item.FilterOption); } if (item.OrderByOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += "$orderby=" + nodeToStringBuilder.TranslateOrderByClause(item.OrderByOption); } if (item.SelectAndExpand != null) { string selectExpand = this.TranslateSelectExpandClause(item.SelectAndExpand, false); res = string.Concat(res, !string.IsNullOrEmpty(res) && !string.IsNullOrEmpty(selectExpand) ? ";" : null, selectExpand); } if (item.TopOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += "$top=" + item.TopOption.ToString(); } if (item.SkipOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += "$skip=" + item.SkipOption.ToString(); } if (item.CountOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += "$count"; res += ExpressionConstants.SymbolEqual; if (item.CountOption == true) { res += ExpressionConstants.KeywordTrue; } else { res += ExpressionConstants.KeywordFalse; } } if (item.SearchOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += "$search"; res += ExpressionConstants.SymbolEqual; res += nodeToStringBuilder.TranslateSearchClause(item.SearchOption); } if (item.LevelsOption != null) { res += string.IsNullOrEmpty(res) ? null : ";"; res += ExpressionConstants.QueryOptionLevels; res += ExpressionConstants.SymbolEqual; res += NodeToStringBuilder.TranslateLevelsClause(item.LevelsOption); } return(string.Concat(currentExpandClause, string.IsNullOrEmpty(res) ? null : string.Concat(ExpressionConstants.SymbolOpenParen, res, ExpressionConstants.SymbolClosedParen))); }