internal static ClientQueryableResult <T> Retrieve <T>(ClientQueryable <T> clientQueryable) where T : ClientObject
        {
            Expression expression = clientQueryable.Expression;
            ClientQueryableResult <T> clientQueryableResult           = new ClientQueryableResult <T>();
            ClientObject rootClientObjectForClientQueryableExpression = DataRetrieval.GetRootClientObjectForClientQueryableExpression(expression);

            if (rootClientObjectForClientQueryableExpression == null)
            {
                throw new InvalidQueryExpressionException();
            }
            ClientQueryInternal clientQueryInternal = new ClientQueryInternal(rootClientObjectForClientQueryableExpression, null, false, null);

            rootClientObjectForClientQueryableExpression.Context.AddQueryIdAndResultObject(clientQueryInternal.Id, clientQueryableResult);
            rootClientObjectForClientQueryableExpression.Context.AddQuery(clientQueryInternal);
            DataRetrieval.QueryProcessInfo      queryProcessInfo      = new DataRetrieval.QueryProcessInfo();
            DataRetrieval.QueryMethodAggregator queryMethodAggregator = new DataRetrieval.QueryMethodAggregator(expression);
            DataRetrieval.ProcessQueryExpression(clientQueryInternal, rootClientObjectForClientQueryableExpression, expression, false, queryProcessInfo, queryMethodAggregator);
            queryMethodAggregator.Check();
            if (queryMethodAggregator.Include == 0)
            {
                clientQueryInternal.ChildItemQuery.SelectAllProperties();
            }
            queryProcessInfo.FinalProcess();
            return(clientQueryableResult);
        }
Beispiel #2
0
        public IEnumerable <T> LoadQuery <T>(IQueryable <T> clientObjects) where T : ClientObject
        {
            if (clientObjects == null)
            {
                throw new ArgumentNullException("clientObjects");
            }
            ClientAction.CheckActionParameterInContext(this, clientObjects);
            ClientObjectCollection <T> clientObjectCollection = clientObjects as ClientObjectCollection <T>;

            if (clientObjectCollection != null)
            {
                return(this.LoadQuery <T>(clientObjectCollection));
            }
            ClientQueryable <T> clientQueryable = clientObjects as ClientQueryable <T>;

            if (clientQueryable != null)
            {
                return(DataRetrieval.Retrieve <T>(clientQueryable));
            }
            throw new NotSupportedException();
        }