コード例 #1
0
        public void CreateRelationship()
        {
            InstanceHandle keyClass     = oms.GetInstance(KnownInstanceGuids.Classes.Class);
            InstanceHandle keyAttribute = oms.GetInstance(KnownInstanceGuids.Classes.Attribute);

            oms.BeginTransaction();

            InstanceHandle keyRelationship = oms.CreateRelationshipInstance(keyClass, "has test relationship", keyAttribute);

            // Class.has test relationship Attribute
            oms.CreateRelationship(keyClass, keyRelationship, keyAttribute);

            oms.CommitTransaction();

            InstanceHandle[] keys = oms.GetRelatedInstances(keyClass, keyRelationship);
            Assert.NotNull(keys);

            Assert.AreEqual(1, keys.Length);

            Assert.AreEqual(keyAttribute, keys[0]);
        }