Example #1
0
        private static ExecuteQueryFunc <Object> CreateDelegate(Type elementType, ExecuteQueryFunc <Object> execFunc)
        {
            MethodInfo execMethodInfo = execFunc.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(elementType);
            var        execFuncType   = execFunc.GetType().GetGenericTypeDefinition().MakeGenericType(elementType);

            return((ExecuteQueryFunc <Object>)execMethodInfo.CreateDelegate(execFuncType));
        }
Example #2
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));
            }
        }