ice.NET Key Concepts: Folders
Folders are containers for objects. Every object is contained in exactly one folder.
Folders are organized in a hierarchy. Every repository has exactly one root folder.
The hierarchical structure beneath the root folder is arbitrary.
Relationships between objects can span across folders.
Example
This example shows how to use the IFolder.CreateChild method
to create folders.
Repository.ExecuteTransaction(delegate()
{
IFolder pDataFolder = Repository.RootFolder.CreateChild("Data", "");
IFolder pCarsFolder = pDataFolder.CreateChild("Cars", "");
});
This example shows how to retrieve child folders and objects. The
IFolder.GetObjects(IObjType, bool, int) method allows to filter by object type
and to restrict the number of results.
foreach (IFolder pFolder in Repository.RootFolder.GetChildFolders())
{
Console.WriteLine("Folder " + pFolder.Name);
IObject[] aAllObjects = pFolder.GetObjects();
Console.WriteLine(" Objects: " + aAllObjects.Length);
IObject[] aVehicles = pFolder.GetObjects(Repository.GetObjTypeByName("PDTec.ICR.Vehicle"), false, 0);
Console.WriteLine(" Vehicles: " + aVehicles.Length);
}