Sunday, May 15, 2005

[Opf3] Using multiple storages

Opf3 allows you to use multiple storages and multiple contexts in one thread of your application. The following sample shows the usage of two instances of the ObjectContext class to copy data from one storage to another.

ObjectContext context1 = new ObjectContext(new AccessStorage(" connectionstring "));
ObjectContext context2 = new ObjectContext(new MsSql2000Storage(" connectionstring "));

ObjectReader<User> or = context1.getObjectReader<User>();
foreach(User user in or)

The sample loads all user objects from the first storage by using an ObjectReader. An ObjectReader is similar to the IDataReader of the .NET framework. The class represents a storage forward-only cursor that allows to go through all objects in the storage and process them somehow.


Post a Comment

<< Home