Beispiel #1
0
        private async Task <IList> ExecuteOe <T, TResult>(LambdaExpression lambda, int maxPageSize)
        {
            Container container = CreateContainer(maxPageSize);
            var       visitor   = new TypeMapperVisitor(container)
            {
                TypeMap = t => Type.GetType("ODataClient." + t.FullName)
            };
            var call = visitor.Visit(lambda.Body);

            IQueryable query = GetQuerableOe(container, typeof(T));
            Type       elementType;

            if (call.Type.GetTypeInfo().IsGenericType)
            {
                elementType = call.Type.GetGenericArguments()[0];
                ExecuteQueryFuncAsync <Object> func = ExecuteQueryAsync <Object>;
                return(await CreateDelegate(elementType, func)(query, call, visitor.NavigationPropertyAccessors));
            }
            else
            {
                elementType = typeof(Object);
                ExecuteQueryFunc <Object> func = ExecuteQueryScalar <Object>;
                return(CreateDelegate(elementType, func)(query, call));
            }
        }
Beispiel #2
0
        private IList ExecuteOe <T, TResult>(LambdaExpression lambda)
        {
            Container  container = CreateContainer();
            IQueryable query     = GetQuerableOe <T>(container);
            var        visitor   = new TypeMapperVisitor(query)
            {
                TypeMap = t => Type.GetType("ODataClient." + t.FullName)
            };
            var call = visitor.Visit(lambda.Body);

            Type elementType;
            ExecuteQueryFunc <Object> func;

            if (call.Type.GetTypeInfo().IsGenericType)
            {
                elementType = call.Type.GetGenericArguments()[0];
                func        = ExecuteQuery <Object>;
            }
            else
            {
                elementType = typeof(Object);
                func        = ExecuteQueryScalar <Object>;
            }

            IList fromOe = CreateDelegate(elementType, func)(query, call);

            TestHelper.SetNullCollection(fromOe, GetIncludes(lambda));

            if (typeof(TResult) == typeof(Object))
            {
                fromOe = TestHelper.SortProperty(fromOe);
            }
            return(fromOe);
        }