private void InvokeCommandWithQuota(ICommand command, DataServiceQueryProvider.ResultSet resultSet) { try { if (command.GetType() != typeof(ReferenceInstanceBuilderCommand)) { DataServiceController.Current.QuotaSystem.CheckCmdletExecutionQuota(this.userContext); } IEnumerator <DSResource> enumerator = command.InvokeAsync(new List <DSResource>().AsQueryable <DSResource>().Expression, true); while (enumerator.MoveNext()) { resultSet.Add(enumerator.Current); } } catch (Exception exception1) { Exception exception = exception1; Tracer tracer = new Tracer(); tracer.ExceptionMessage(exception.Message); throw; } }
internal DataServiceQueryProvider.ResultSet GetAssociatedInstances(IQueryable <DSResource> source, ResourceProperty property) { EntityMetadata entityMetadatum = null; DataServiceQueryProvider.ResultSet resultSet; using (OperationTracer operationTracer = new OperationTracer("ProcessExpression")) { if (this.schema.EntityMetadataDictionary.TryGetValue(property.ResourceType.FullName, out entityMetadatum)) { DataServiceQueryProvider.ResultSet resultSet1 = new DataServiceQueryProvider.ResultSet(property.ResourceType); IEnumerable <DSResource> uniqueKeys = this.GetUniqueKeys(source, property); foreach (DSResource uniqueKey in uniqueKeys) { if (!uniqueKey.ContainsNonKeyProperties) { ICommand command = DataServiceController.Current.GetCommand(CommandType.Read, this.userContext, property.ResourceType, entityMetadatum, this.membershipId); using (command) { UriParametersHelper.AddParametersToCommand(command, DataServiceController.Current.GetCurrentResourceUri()); foreach (ResourceProperty keyProperty in property.ResourceType.KeyProperties) { if (command.AddFieldParameter(keyProperty.Name, uniqueKey.GetValue(keyProperty.Name, null))) { continue; } object[] name = new object[2]; name[0] = property.ResourceType.Name; name[1] = keyProperty.Name; string str = string.Format(CultureInfo.CurrentCulture, Resources.KeyParameterFailed, name); throw new NotImplementedException(str); } try { DataServiceController.Current.QuotaSystem.CheckCmdletExecutionQuota(this.userContext); IEnumerator <DSResource> enumerator = command.InvokeAsync(new List <DSResource>().AsQueryable <DSResource>().Expression, true); while (enumerator.MoveNext()) { resultSet1.Add(enumerator.Current); } } catch (Exception exception1) { Exception exception = exception1; Tracer tracer = new Tracer(); tracer.ExceptionMessage(exception.Message); throw; } } } else { resultSet1.Add(uniqueKey); } } resultSet = resultSet1; } else { object[] objArray = new object[1]; objArray[0] = property.Name; throw new UnauthorizedAccessException(ExceptionHelpers.GetExceptionMessage(Resources.NoAccessToNavProperty, objArray)); } } return(resultSet); }