From Sense/Net Wiki
Jump to: navigation, search
  • 100%
  • 6.4 Patch 1
  • Enterprise
  • Community
  • Planned


Sense/Net ECM stores all data in the Content Repository in a huge tree built of Content items. These individual content items are saved in an atomic operation inside a transaction, and any other save operation that tries to modify the same content will be rejected. There are cases however when the same functionality would be useful for a whole subtree - e.g. a folder and its children, or a whole workspace. This article describes how we do this in Sense/Net ECM.

This is a feature designed for supporting low-level operations like move or delete. Please consider carefully before trying to use this API.


It is possible to lock a subtree in the Content Repository. This means that for the lifetime of that lock it is not possible to modify the content under that subtree - even for the caller itself.

The TreeLock class provides a simple API for acquiring and releasing a lock for a subtree, or checking whether a certain subtree is free of lock.

Acquiring the lock

Using the static Acquire method of the TreeLock class you can acquire a tree lock object for one or more sub trees. If any of the provided sub trees are already locked, an exception will be thrown.

Check for existing lock

The TreeLock.AssertFree method lets you check if there is already a lock in the database related to the provided sub trees.

Releasing the lock

Despite the lock is persisted to the database, this feature is meant to be used for relatively short in-memory operations. It is essential to release the lock after the desired operation was done. You may do this by disposing the tree lock object manually or simply using a using block when acquiring the lock.


The following example shows how can you acquire a tree lock for a certain subtree.

using (TreeLock.Acquire(path))
    // safe code goes here that needs the Content subtree to be intact

Related links


There are no related external articles for this article.