private void AddPropertyUpdates(ICommand command) { foreach (KeyValuePair <string, object> propertyUpdate in this.propertyUpdates) { Func <ResourceProperty, bool> func = null; KeyValuePair <string, object> keyValuePair1 = propertyUpdate; if (!command.CanFieldBeAdded(keyValuePair1.Key)) { continue; } KeyValuePair <string, object> keyValuePair2 = propertyUpdate; object value = keyValuePair2.Value; value = EntityUpdate.ResolveUpdatableObject(value); value = EntityUpdate.ResolveUpdatableObjectList(value); if (value == null && this.commandType == CommandType.Create) { ReadOnlyCollection <ResourceProperty> properties = this.resourceType.Properties; if (func == null) { func = (ResourceProperty item) => { KeyValuePair <string, object> keyValuePair = propertyUpdate; return(item.Name == keyValuePair.Key); } ; } ResourceProperty resourceProperty = properties.First <ResourceProperty>(func); if (resourceProperty.ResourceType.IsNullable()) { continue; } } KeyValuePair <string, object> keyValuePair3 = propertyUpdate; command.AddFieldParameter(keyValuePair3.Key, value); } }
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); }
private void AddPropertyUpdates(ICommand command) { foreach (KeyValuePair<string, object> propertyUpdate in this.propertyUpdates) { Func<ResourceProperty, bool> func = null; KeyValuePair<string, object> keyValuePair1 = propertyUpdate; if (!command.CanFieldBeAdded(keyValuePair1.Key)) { continue; } KeyValuePair<string, object> keyValuePair2 = propertyUpdate; object value = keyValuePair2.Value; value = EntityUpdate.ResolveUpdatableObject(value); value = EntityUpdate.ResolveUpdatableObjectList(value); if (value == null && this.commandType == CommandType.Create) { ReadOnlyCollection<ResourceProperty> properties = this.resourceType.Properties; if (func == null) { func = (ResourceProperty item) => { KeyValuePair<string, object> keyValuePair = propertyUpdate; return item.Name == keyValuePair.Key; } ; } ResourceProperty resourceProperty = properties.First<ResourceProperty>(func); if (resourceProperty.ResourceType.IsNullable()) { continue; } } KeyValuePair<string, object> keyValuePair3 = propertyUpdate; command.AddFieldParameter(keyValuePair3.Key, value); } }