Beispiel #1
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);
        }