Exemplo n.º 1
0
        private static IList <string> GetMappedColumnList(ObjectQueryExecutionPlan plan)
        {
            // Get the column name position map in cspace.
            var columnNamePosMap = ELinqQueryState.GetColumnNamePositionMap(plan);

            if (columnNamePosMap == null || columnNamePosMap.Keys.Count == 0)
            {
                // Skip Generation if no Mapping Exists
                return(null);
            }

            var resultRowTypes = ELinqQueryState.GetMappedCommandReturnTypes(plan);

            if (resultRowTypes == null || !resultRowTypes.Any())
            {
                return(null);
            }

            IList <string> mappedColumnListSSpace = new List <string>();

            foreach (var mapped in columnNamePosMap)
            {
                EdmProperty property = resultRowTypes[0].Properties[mapped.Value];
                mappedColumnListSSpace.Add(property.Name);
            }

            return(mappedColumnListSSpace);
        }
        internal override ObjectQueryState Include <TElementType>(
            ObjectQuery <TElementType> sourceQuery,
            string includePath)
        {
            MethodInfo       includeMethod = ELinqQueryState.GetIncludeMethod <TElementType>(sourceQuery);
            ObjectQueryState other         = (ObjectQueryState) new ELinqQueryState(this.ElementType, this.ObjectContext, (Expression)Expression.Call((Expression)Expression.Constant((object)sourceQuery), includeMethod, (Expression)Expression.Constant((object)includePath, typeof(string))), (ObjectQueryExecutionPlanFactory)null);

            this.ApplySettingsTo(other);
            return(other);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Returns a new ObjectQueryState instance with the specified navigation property path specified as an Include span.
        ///     For eLINQ queries the Include operation is modelled as a method call expression applied to the source ObectQuery,
        ///     so the <see cref="Span" /> property is always <c>null</c> on the returned instance.
        /// </summary>
        /// <typeparam name="TElementType"> The element type of the resulting query </typeparam>
        /// <param name="sourceQuery"> The ObjectQuery on which Include was called; required to build the new method call expression </param>
        /// <param name="includePath"> The new Include path </param>
        /// <returns> A new ObjectQueryState instance that incorporates the Include path, in this case a new method call expression </returns>
        internal override ObjectQueryState Include <TElementType>(ObjectQuery <TElementType> sourceQuery, string includePath)
        {
            var includeMethod = sourceQuery.GetType().GetMethod("Include", BindingFlags.Public | BindingFlags.Instance);

            Debug.Assert(includeMethod != null, "Unable to find ObjectQuery.Include method?");

            Expression includeCall = Expression.Call(
                Expression.Constant(sourceQuery), includeMethod, new Expression[] { Expression.Constant(includePath, typeof(string)) });
            ObjectQueryState retState = new ELinqQueryState(ElementType, ObjectContext, includeCall);

            ApplySettingsTo(retState);
            return(retState);
        }
Exemplo n.º 4
0
 public void GetIncludeMethod_returns_query_Include_MethodInfo()
 {
     Assert.NotNull(ELinqQueryState.GetIncludeMethod(new ObjectQuery <int>()));
 }