/// <summary> /// Translates resource bound expression tree to a URI. /// </summary> /// <param name='context'>Data context used to generate type names for types.</param> /// <param name="addTrailingParens">flag to indicate whether generated URI should include () if leaf is ResourceSet</param> /// <param name="e">The expression to translate</param> /// <param name="uri">uri</param> /// <param name="version">version for query</param> internal static void Translate(DataServiceContext context, bool addTrailingParens, Expression e, out Uri uri, out Version version) { var writer = new UriWriter(context); writer.Visit(e); string fullUri = writer.uriBuilder.ToString(); if (writer.alias.Any()) { if (fullUri.IndexOf(UriHelper.QUESTIONMARK) > -1) { fullUri += UriHelper.AMPERSAND; } else { fullUri += UriHelper.QUESTIONMARK; } foreach (var kv in writer.alias) { fullUri += kv.Key; fullUri += UriHelper.EQUALSSIGN; fullUri += kv.Value; fullUri += UriHelper.AMPERSAND; } fullUri = fullUri.Substring(0, fullUri.Length - 1); } uri = UriUtil.CreateUri(fullUri, UriKind.Absolute); version = writer.uriVersion; }
/// <summary> /// Translates resource bound expression tree to a URI. /// </summary> /// <param name='context'>Data context used to generate type names for types.</param> /// <param name="addTrailingParens">flag to indicate whether generated URI should include () if leaf is ResourceSet</param> /// <param name="e">The expression to translate</param> /// <param name="uri">uri</param> /// <param name="version">version for query</param> internal static void Translate(DataServiceContext context, bool addTrailingParens, Expression e, out Uri uri, out Version version) { var writer = new UriWriter(context); writer.leafResource = addTrailingParens ? (e as QueryableResourceExpression) : null; writer.Visit(e); uri = UriUtil.CreateUri(writer.uriBuilder.ToString(), UriKind.Absolute); version = writer.uriVersion; }