This class contains all the event fired by C1 CMS when changes are made to data items. Use OnStoreChanged to catch any data change event, including events originating from other servers in a load balance setup or changes made directly to a store (which C1 CMS can detect). This event do not contain details about the specific data item changed and is raised after the fact. Use the more detailed operations to catch data events that happen in the current website process. The 'OnBefore' events enable you to manipulate data before they are stored. The 'OnAfter' events let you react to data changes in detail, for instance updating a cache. A combination of OnStoreChanged and the detailed data events can be used to create a highly optimized cache.

Namespace: Composite.Data
Assembly: Composite (in Composite.dll) Version: 6.1.6325.31818


public static class DataEvents<TData>
where TData : class, IData
Visual Basic
Public NotInheritable Class DataEvents(Of TData As {Class, IData})
Visual C++
generic<typename TData>
where TData : ref class, IData
public ref class DataEvents abstract sealed

Type Parameters

Data type to attach events to


void MyMethod()
   DataEvents<IMyDataType>.OnBeforeAdd += new DataEventHandler(DataEvents_OnBeforeAdd);
   DataEvents<IMyDataType>.OnStoreChanged += new StoreEventHandler(DataEvents_OnStoreChanged);

   using (DataConnection connection = new DataConnection())
      IMyDataType myDataType = DataConnection.New<IMyDataType>();
      myDataType.Name = "Foo";

      connection.Add<IMyDataType>(myDataType); // This will fire both of the the events in the local process!
      // if other servers share data store with this site they will see OnStoreChanged fire.

void DataEvents_OnBeforeAdd(object sender, DataEventArgs dataEventArgs)
    // here a minor update to the cache could be done (like adding info about the new element only).

void DataEvents_OnStoreChanged(object sender, StoreEventArgs storeEventArgs)
    if (!storeEventArgs.DataEventsFired)
        // an external update event happened - DataEvents_OnBeforeAdd not fired
        // here a complete cache flush could be done

Inheritance Hierarchy

  Composite.Data..::..DataEvents<(Of <(<'TData>)>)>

See Also