MDS WebService - adding Number or DateTime MetadataAttribute
-
Tuesday, September 18, 2012 7:26 PM
I am currently using the WebService to dynamically build a model in MDS (SQL Server 2008 R2). All seems to be working fine with one exception so far - when I add a Number or DateTime attribute to an entity, it (and all attributes I added after it) does not appear in the Leaf Attributes section of the Edit Entity screen in System Administration until I go in and edit an attribute that does exist and simply save it. I am thinking that maybe I am missing something in my code when I add the new MetadataAttribute. Here is an excerpt of my code:
public MDS.OperationResult AddAttribute(MDS.Identifier modelId, MDS.Identifier versionId, MDS.Identifier entityId, string attributeName, MDS.AttributeType attType, MDS.AttributeDataType attDataType, int dataTypeInfo, string mask, MDS.Identifier dbaEntityId) { MDS.OperationResult or = null; MDS.Metadata md = new MDS.Metadata(); or = new MDS.OperationResult(); md = GetMetaData(new MDS.International(), ref or, modelId, versionId, entityId, MDAction.AttributesOnly); MDS.MetadataAttribute ma = null; if (attType == MDS.AttributeType.FreeForm) { if (attDataType != MDS.AttributeDataType.DateTime) { MDS.Identifier maskID = null; if (!string.IsNullOrEmpty(mask)) { maskID = new MDS.Identifier() { Name = mask }; } ma = new MDS.MetadataAttribute() { AttributeType = attType, Identifier = new MDS.MemberTypeContextIdentifier() { EntityId = entityId, ModelId = modelId, MemberType = MDS.MemberType.Leaf, Name = attributeName }, DataType = attDataType, DataTypeInformation = dataTypeInfo, InputMaskId = maskID, DisplayWidth = 100 }; } else { MDS.Identifier maskID = null; if (!string.IsNullOrEmpty(mask)) { maskID = new MDS.Identifier() { Name = mask }; } ma = new MDS.MetadataAttribute() { AttributeType = attType, Identifier = new MDS.MemberTypeContextIdentifier() { EntityId = entityId, ModelId = modelId, MemberType = MDS.MemberType.Leaf, Name = attributeName }, DataType = attDataType, InputMaskId = maskID, DisplayWidth = 100 }; } } List<MDS.MetadataAttribute> lst = md.Attributes.ToList<MDS.MetadataAttribute>(); lst.Add(ma); md.Attributes = lst.ToArray(); MDS.ServiceClient proxy = CreateMdsProxy(); proxy.MetadataCreate(International, md, true, out or); return or; }Any feedback would be appreciated. Thanks!

