IRelationshipClassEvents Interface

Provides access to events that occur with a relationship class.

Description

Both the RelationshipClass and AttributedRelationshipClass object support IRelationshipClassEvents as an outoing interface to provide events when Relationship objects are created, deleted and changed. A Relationship object supporting IRelationship is passed in to allow you to identify the origin and destination objects as well as the RelationshipClass itself.

Appropriate places to begin listening to IRelationshipClassEvents on a RelationshipClass include from within an Editor Extension or within a Class Extension. You must specifically identify the RelationshipClass that you wish to listen to events on.

OnCreate is fired if you create a new simple or attributed relationship in one of the following ways :

  • Call IRelationshipClass.CreateRelationship
  • Call ITable.CreateRow on an AttributedRelationshipClass

Note that if you call IRelationshipClass.CreateRelationship on a simple relationship this changes the foreign key inside the destination object to point to the new origin object: i.e the old relationship is deleted in creating the new relationship. No OnDelete event will be fired corresponding to this implicit deletion. An application may be interested in the details of the relationship that was implicitly deleted. This can be achieved by getting the ISimpleRelationshipChanges interface on the Relationship object passed in to the OnCreate event. This interface has a single property OldOriginKey that the application can use to get the key of the origin object. Any further fetching of the old origin object is up to the application using this key.

OnDelete is fired if you delete a simple or attributed relationship in one of the following ways:

  • Call IRelationshipClass.DeleteRelationship
  • Call IRow.Delete on an AttributedRelationship

OnChange is fired if you do any of the following:

  • Update an attribute value of an AttributedRelationshipClass

Note that one can also create and delete relationships implicitly by directly using put_Value to set the origin foreign key field inside the destination object in the case of a simple relationship class. However, no events in IRelationshipClassEvents will be fired if the user does this (for eg. uses the Table document to directly set foreign key values in the destination object).

An application wishing to track such changes must listen to IObjectClassEvents.OnChange on the destination object class and track changes to the foreign key using IRowChanges. Note that IObjectClassEvents.OnChange will not be fired on the destination object class in a simple relationship class if the user changes the foreign key value using IRelationshipClass.CreateRelationship or IRelationshipClass.DeleteRelationship

It is important to note that retrieving the origin object or the destination object will issue queries against the database to retrieve the object requrested. This can slow down the process of creating/modifying relationships - This is specially true for attributed relationships.

Members

Name Description
Method OnChange This event is fired when a relationship's attributes are updated.
Method OnCreate This event is fired when a new relationship is created in the relationship class.
Method OnDelete This event is fired when an relationship is deleted from the relationship class.

IRelationshipClassEvents.OnChange Event

This event is fired when a relationship's attributes are updated.

Public Event OnChange As OnChangeEventHandler
public event OnChangeEventHandler OnChange

Description

OnChange is fired if you do any of the following:

  • Update an attribute value of an AttributedRelationshipClass

IRelationshipClassEvents.OnCreate Event

This event is fired when a new relationship is created in the relationship class.

Public Event OnCreate As OnCreateEventHandler
public event OnCreateEventHandler OnCreate

Description

OnCreate is fired if you create a new simple or attributed relationship in one of the following ways :

  • Call IRelationshipClass.CreateRelationship
  • Call ITable.CreateRow on an AttributedRelationshipClass

Note that if you call IRelationshipClass::CreateRelationship on a simple relationship this changes the foreign key inside the destination object to point to the new origin object : i.e the old relationship is deleted in creating the new relationship. No OnDelete event will be fired corresponding to this implicit deletion. An application may be interested in the details of the relationship that was implicitly deleted. This can be achieved by getting the ISimpleRelationshipChanges interface on the Relationship object passed in to the OnCreate event. This interface has a single property OldOriginKey that the application can use to get the key of the origin object. Any further fetching of the old origin object is up to the application using this key.

Note that one can also create and delete relationships implicitly by directly using put_Value to set the origin foreign key field inside the destination object in the case of a simple relationship class. However, no events in IRelationshipClassEvents will be fired if the user does this (for eg. uses the Table document to directly set foreign key values in the destination object).

IRelationshipClassEvents.OnDelete Event

This event is fired when an relationship is deleted from the relationship class.

Public Event OnDelete As OnDeleteEventHandler
public event OnDeleteEventHandler OnDelete

Description

OnDelete is fired if you delete a simple or attributed relationship in one of the following ways:

  • Call IRelationshipClass.DeleteRelationship
  • Call IRow.Delete on an AttributedRelationship

Note that one can also create and delete relationships implicitly by directly using put_Value to set the origin foreign key field inside the destination object in the case of a simple relationship class. However, no events in IRelationshipClassEvents will be fired if the user does this (for eg. uses the Table document to directly set foreign key values in the destination object).

Classes that implement IRelationshipClassEvents

Classes Description
RelationshipClassEvents Helper coclass for working with the outbound interface on noncreatable relationship classes in VB.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.