Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Adding Database Objects to the Container
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > The OpenAccess ORM Disconnected API > Adding Database Objects to the Container

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

You copy objects from an object scope to the container with the ObjectContainer method CopyFrom(). This method takes an IObjectScope instance, the listname, the object to be copied as arguments and an IObjectCollector interface:

C# Copy Code
void CopyFrom( IObjectScope objectScope, String listName, Object objectToBeAdded, IObjectCollector objectCollector )  
VB .NET Copy Code
void CopyFrom(IObjectScope objectScope, String listName, Object objectToBeAdded, IObjectCollector objectCollector)


The source IObjectScope to copy from.


The name of the list under which the added objects should be retrievable. Can also be null.


An object that is to be added to the container. The objectToBeAdded parameter specifies the "root objects" that are to be added to the container. All the root objects are added to a "named list". This list can be used to later retrieve the root objects.

It can also be type IEnumerable or IEnumerator in which case all contained objects are added to the container.

In the case where a persistent capable class also implements IEnumerable or IEnumerator, the object graph for only this class's object is calculated. The contained objects are not enumerated.


An implementation of the IObjectCollector interface used to calculate the object graph for each of the root objects. It can also specify that objects referenced by the "root objects" need to be copied and added to the container. In this case the "root objects" are added to both, the named list and the container, whereas the referenced objects are added only to the container.

This parameter can be null, in which case only the root objects are added to the container.

If the object data is not in memory, it is retrieved from database. A copy of the object is made and this copy is added to the container

You can also add a collection of objects to the container. The collection could, for example, be the result of a query:

C# Copy Code
OpenAccess.Oql.Query query =
 new OpenAccess.Oql.Query( "SELECT * FROM CustomerExtent" );
IEnumerator e = scope.Query.Execute( query ).GetEnumerator();
container.CopyFrom( scope, e );
VB .NET Copy Code
Dim query As New OpenAccess.Oql.Query("SELECT * FROM CustomerExtent")
Dim e As IEnumerator = scope.Query.Execute(query).GetEnumerator()
container.CopyFrom(scope, e)

The objects are copied individually to the container, not as complete object graphs. The objects in the database are not modified in any way by being copied to the container.

Object References and Proxies

References from the copied objects to objects outside of the container are expressed by a "hollow" object inside the object container. These hollow objects within a container are referred to as proxy objects. In contrast to hollow objects in an object scope, proxy objects in the container cannot be resolved automatically since the container does not have a database connection. The object data is detached from the database.

The container uses the proxy object to model an otherwise incomplete object graph. For example, if you call the container CopyFrom() method for a single object that has references to other objects, the referenced objects will exist in the container as proxies. This allows you to edit the object with proxy references as if the referenced objects were there in the container. Of course, the data in the object represented by the proxy is not available. If the actual referenced objects are needed inside the container you need to explicitly copy them or use the IObjectCollector Collect() method. If an object was represented as a proxy in the container, the proxy will be replaced by the correct representation with full data. No database object is held twice in the container, i.e. the container holds unique database objects.

IObjectCollector Interface

The IObjectCollector interface is used for obtaining entire network of objects.

This interface can be used to obtain a list of persistence capable objects which are reachable from the "root object", which is specified in its Collect() method. This is useful while filling an ObjectContainer instance; usually your application model will require some object graphs to be present while working offline. An object collector can be used to find specific instances, (for example, the address instance of the person class) so that the object container can make a copy of them.

The application might use multiple implementations of this interface.

One implementation of this interface is provided in the form of the FetchGroupCollector class (Refer to The FetchGroup Collector for more information).