// Update the attribute name. private static void UpdateAttribute(Guid modelId, Guid entityId, Guid attributeId, string newAttributeName) { try { // Create the request object for updating attribute information. MetadataUpdateRequest updateRequest = new MetadataUpdateRequest(); updateRequest.Metadata = new Metadata(); updateRequest.Metadata.Attributes = new System.Collections.ObjectModel.Collection <MetadataAttribute> { }; // Set model id, entity id, attribute id, and new attribute name. MetadataAttribute anAttribute = new MetadataAttribute { Identifier = new MemberTypeContextIdentifier { Name = newAttributeName, Id = attributeId, ModelId = new Identifier { Id = modelId }, EntityId = new Identifier { Id = entityId }, MemberType = MDSTestService.MemberType.Leaf } }; updateRequest.Metadata.Attributes.Add(anAttribute); // Update the attribute information. MetadataUpdateResponse updateResponse = clientProxy.MetadataUpdate(updateRequest); HandleOperationErrors(updateResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Update the model name. private static void UpdateModel(Guid modelId, string newModelName) { try { // Create the request object for updating model information. MetadataUpdateRequest updateRequest = new MetadataUpdateRequest(); updateRequest.Metadata = new Metadata(); updateRequest.Metadata.Models = new System.Collections.ObjectModel.Collection <Model> { }; Model aModel = new Model(); aModel.Identifier = new Identifier { Id = modelId, Name = newModelName }; updateRequest.Metadata.Models.Add(aModel); // Update the model information. MetadataUpdateResponse updateResponse = clientProxy.MetadataUpdate(updateRequest); HandleOperationErrors(updateResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Update the entity name. private static void UpdateEntity(Guid modelId, Guid entityId, string newEntityName) { try { // Create the request object for updating entity information. MetadataUpdateRequest updateRequest = new MetadataUpdateRequest(); updateRequest.Metadata = new Metadata(); updateRequest.Metadata.Entities = new System.Collections.ObjectModel.Collection <Entity> { }; Entity anEntity = new Entity(); // Set model id, entity id, and the new entity name. anEntity.Identifier = new ModelContextIdentifier { Id = entityId, Name = newEntityName, ModelId = new Identifier { Id = modelId } }; updateRequest.Metadata.Entities.Add(anEntity); // Update the entity information. MetadataUpdateResponse updateResponse = clientProxy.MetadataUpdate(updateRequest); HandleOperationErrors(updateResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
private static void SetApprovalRequired(string modelName, string entityName, bool approvalRequired) { var updateRequest = new MetadataUpdateRequest { Metadata = new Metadata { Entities = new Collection <Entity> { new Entity { Identifier = new ModelContextIdentifier { Name = entityName, ModelId = new Identifier { Name = modelName } }, RequireApproval = approvalRequired } } } }; MetadataUpdateResponse updateResponse = clientProxy.MetadataUpdate(updateRequest); HandleOperationErrors(updateResponse.OperationResult); }