// Create an attribute with a specified name. private static void CreateAttribute(Guid modelId, Guid entityId, string attributeName) { try { // Create the request object for attribute creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.Attributes = new System.Collections.ObjectModel.Collection<MetadataAttribute> { }; MetadataAttribute newAttribute = new MetadataAttribute(); // Set model id, entity id, and attribute name. newAttribute.Identifier = new MemberTypeContextIdentifier { Name = attributeName, ModelId = new Identifier { Id = modelId }, EntityId = new Identifier { Id = entityId }, MemberType = MemberType.Leaf }; newAttribute.AttributeType = AttributeType.FreeForm; newAttribute.DataType = AttributeDataType.Text; // When the DataType is "Text", set the length (100) to DataTypeInformation. newAttribute.DataTypeInformation = 100; newAttribute.DisplayWidth = 100; createRequest.Metadata.Attributes.Add(newAttribute); // Create a new attribute MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Create an attribute group with a specified name. private static void CreateAttributeGroup(Guid modelId, Guid entityId, string attributeGroupName) { try { // Create the request object for attribute group creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.AttributeGroups = new System.Collections.ObjectModel.Collection<AttributeGroup> { }; AttributeGroup newAttributeGroup = new AttributeGroup(); // Set model id, entity id, and attribute group name. newAttributeGroup.Identifier = new MemberTypeContextIdentifier { Name = attributeGroupName, ModelId = new Identifier { Id = modelId }, EntityId = new Identifier { Id = entityId }, MemberType = MemberType.Leaf }; newAttributeGroup.FullName = attributeGroupName; createRequest.Metadata.AttributeGroups.Add(newAttributeGroup); // Create a new attribute group. MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Create an attribute group with a specified name. private static void CreateAttributeGroup(Guid modelId, Guid entityId, string attributeGroupName) { try { // Create the request object for attribute group creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.AttributeGroups = new System.Collections.ObjectModel.Collection <AttributeGroup> { }; AttributeGroup newAttributeGroup = new AttributeGroup(); // Set model id, entity id, and attribute group name. newAttributeGroup.Identifier = new MemberTypeContextIdentifier { Name = attributeGroupName, ModelId = new Identifier { Id = modelId }, EntityId = new Identifier { Id = entityId }, MemberType = MemberType.Leaf }; newAttributeGroup.FullName = attributeGroupName; createRequest.Metadata.AttributeGroups.Add(newAttributeGroup); // Create a new attribute group. MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Create an attribute with a specified name. private static void CreateAttribute(Guid modelId, Guid entityId, string attributeName) { try { // Create the request object for attribute creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.Attributes = new System.Collections.ObjectModel.Collection <MetadataAttribute> { }; MetadataAttribute newAttribute = new MetadataAttribute(); // Set model id, entity id, and attribute name. newAttribute.Identifier = new MemberTypeContextIdentifier { Name = attributeName, ModelId = new Identifier { Id = modelId }, EntityId = new Identifier { Id = entityId }, MemberType = MemberType.Leaf }; newAttribute.AttributeType = AttributeType.FreeForm; newAttribute.DataType = AttributeDataType.Text; // When the DataType is "Text", set the length (100) to DataTypeInformation. newAttribute.DataTypeInformation = 100; newAttribute.DisplayWidth = 100; createRequest.Metadata.Attributes.Add(newAttribute); // Create a new attribute MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Create an entity with a specified name. private static void CreateEntity(Guid modelId, string entityName) { try { // Create the request object for entity creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.Entities = new System.Collections.ObjectModel.Collection <Entity> { }; Entity newEntity = new Entity(); // Set the modelId and the entity name. newEntity.Identifier = new ModelContextIdentifier { Name = entityName, ModelId = new Identifier { Id = modelId } }; createRequest.Metadata.Entities.Add(newEntity); // Create a new entity MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Create a model with a specified name. private static void CreateModel(string modelName) { try { // Create the request object for model creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.Models = new System.Collections.ObjectModel.Collection <Model> { }; Model newModel = new Model(); newModel.Identifier = new Identifier { Name = modelName }; createRequest.Metadata.Models.Add(newModel); // Create a new model. MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
private static Identifier CreateModel(string modelName, string entityName, string explicitHierarchyName) { MetadataCreateRequest createRequest = new MetadataCreateRequest { Metadata = new Metadata { Models = new Collection <Model> { new Model { Identifier = new Identifier { Name = modelName }, Entities = new Collection <Entity> { new Entity { Identifier = new ModelContextIdentifier { Name = entityName, ModelId = new Identifier { Name = modelName } }, ExplicitHierarchies = new Collection <ExplicitHierarchy> { new ExplicitHierarchy { Identifier = new EntityContextIdentifier { Name = explicitHierarchyName, ModelId = new Identifier { Name = modelName }, EntityId = new Identifier { Name = entityName } } } } } } } } }, ReturnCreatedIdentifiers = true }; MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); return(createResponse.MetadataCreated.Models[0].Identifier); }
// Create an entity with a specified name. private static void CreateEntity(Guid modelId, string entityName) { try { // Create the request object for entity creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.Entities = new System.Collections.ObjectModel.Collection<Entity> { }; Entity newEntity = new Entity(); // Set the modelId and the entity name. newEntity.Identifier = new ModelContextIdentifier { Name = entityName, ModelId = new Identifier { Id = modelId } }; createRequest.Metadata.Entities.Add(newEntity); // Create a new entity MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
// Create a model with a specified name. private static void CreateModel(string modelName) { try { // Create the request object for model creation. MetadataCreateRequest createRequest = new MetadataCreateRequest(); createRequest.Metadata = new Metadata(); createRequest.Metadata.Models = new System.Collections.ObjectModel.Collection<Model> { }; Model newModel = new Model(); newModel.Identifier = new Identifier { Name = modelName }; createRequest.Metadata.Models.Add(newModel); // Create a new model. MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex); } }
private static Identifier CreateModel(string modelName, string entityName, string explicitHierarchyName) { MetadataCreateRequest createRequest = new MetadataCreateRequest { Metadata = new Metadata { Models = new Collection<Model> { new Model { Identifier = new Identifier {Name = modelName}, Entities = new Collection<Entity> { new Entity { Identifier = new ModelContextIdentifier { Name = entityName, ModelId = new Identifier {Name = modelName} }, ExplicitHierarchies = new Collection<ExplicitHierarchy> { new ExplicitHierarchy { Identifier = new EntityContextIdentifier { Name = explicitHierarchyName, ModelId = new Identifier {Name = modelName}, EntityId = new Identifier {Name = entityName} } } } } } } } }, ReturnCreatedIdentifiers = true }; MetadataCreateResponse createResponse = clientProxy.MetadataCreate(createRequest); HandleOperationErrors(createResponse.OperationResult); return createResponse.MetadataCreated.Models[0].Identifier; }