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); }
internal static void Load <T>(T clientObject, params Expression <Func <T, object> >[] retrievals) where T : ClientObject { ClientObjectCollection clientObjectCollection = clientObject as ClientObjectCollection; if (retrievals == null || retrievals.Length == 0) { clientObject.Query.SelectAllProperties(); if (clientObjectCollection != null) { clientObject.Query.ChildItemQuery.SelectAllProperties(); return; } } else { DataRetrieval.QueryProcessInfo queryProcessInfo = new DataRetrieval.QueryProcessInfo(); int num = 0; int num2 = 0; for (int i = 0; i < retrievals.Length; i++) { Expression <Func <T, object> > expression = retrievals[i]; DataRetrieval.QueryMethodAggregator queryMethodAggregator = new DataRetrieval.QueryMethodAggregator(expression); DataRetrieval.ProcessQueryExpression(clientObject.Query, clientObject, expression.Body, true, queryProcessInfo, queryMethodAggregator); queryMethodAggregator.Check(); if (queryMethodAggregator.Where > 0 || queryMethodAggregator.Take > 0) { num++; if (num > 1) { throw new InvalidQueryExpressionException(); } } num2 += queryMethodAggregator.Include; if (queryMethodAggregator.IsEmpty) { clientObject.Query.SelectAllProperties(); if (clientObjectCollection != null) { clientObject.Query.ChildItemQuery.SelectAllProperties(); } } } if (clientObjectCollection != null && num2 == 0) { clientObject.Query.ChildItemQuery.SelectAllProperties(); } queryProcessInfo.FinalProcess(); } }