Exemple #1
0
        public static Expression WithTranslations(Expression expression, TranslationMap map)
        {
            Argument.EnsureNotNull("expression", expression);
            Argument.EnsureNotNull("map", map);

            return(new TranslatingVisitor(map).Visit(expression));
        }
        /// <summary>
        /// Create a new <see cref="Expression"/> tree based upon the
        /// <paramref name="expression"/> with translatable properties decomposed back
        /// into their expression trees ready for translation to a remote provider using
        /// the default <see cref="TranslationMap"/>.
        /// </summary>
        /// <param name="expression">Expression tree to translate.</param>
        /// <param name="map"><see cref="TranslationMap"/> used to translate property accesses.</param>
        /// <returns><see cref="Expression"/> tree with translatable expressions translated.</returns>
        public static Expression WithTranslations(Expression expression, TranslationMap map)
        {
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }

            return(new TranslatingVisitor(map).Visit(expression));
        }
Exemple #3
0
 internal TranslatingVisitor(TranslationMap map)
 {
     this.map = map;
 }
Exemple #4
0
 public static Expression WithTranslations(Expression expression, TranslationMap map)
 {
     return(new TranslatingVisitor(map).Visit(expression));
 }
Exemple #5
0
 public static IQueryable <T> WithTranslations <T>(this IQueryable <T> source, TranslationMap map)
 {
     return(source.Provider.CreateQuery <T>(WithTranslations(source.Expression, map)));
 }
Exemple #6
0
        /// <summary>
        /// Create a new <see cref="IQueryable{T}"/> based upon the
        /// <paramref name="source"/> with the translatable properties decomposed back
        /// into their expression trees ready for translation to a remote provider using
        /// a specific <paramref name="map"/>.
        /// </summary>
        /// <typeparam name="T">Result type of the query.</typeparam>
        /// <param name="source">Source query to translate.</param>
        /// <param name="map"><see cref="TranslationMap"/> used to translate property accesses.</param>
        /// <returns><see cref="IQueryable{T}"/> containing translated query.</returns>
        public static IQueryable <T> WithTranslations <T>(this IQueryable <T> source, TranslationMap map)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }

            return(source.Provider.CreateQuery <T>(WithTranslations(source.Expression, map)));
        }
Exemple #7
0
 internal TranslatingVisitor(TranslationMap map)
 {
     this.map = map ?? throw new ArgumentNullException(nameof(map));
 }
Exemple #8
0
            internal TranslatingVisitor(TranslationMap map)
            {
                Argument.EnsureNotNull("map", map);

                this.map = map;
            }
Exemple #9
0
        public static IQueryable <T> WithTranslations <T>(this IQueryable <T> source, TranslationMap map)
        {
            Argument.EnsureNotNull("source", source);
            Argument.EnsureNotNull("map", map);

            return(source.Provider.CreateQuery <T>(WithTranslations(source.Expression, map)));
        }