Db4o gives you a simple and straightforward interface to object persistence - ObjectContainer. In .NET versions a conventional name IObjectContainer is used.
ObjectContainer is your db4o database.
c#: IObjectContainer container = Db4oFactory.OpenFile(filename)
VB: Dim container As IObjectContainer = Db4oFactory.OpenFile(filename)
filename is the path to the file, in which you want to store your objects. Normally you should open an ObjectContainer when the application starts and close it, when the session is finished to persist the changes to a physical storage location:
c#: container.Close()
VB: container.Close()
Applications using db4o versions lower than 6.1can issue multiple calls to open the same file (without closing it). These calls will get the already existing open ObjectContainer instance and no error will be produced. However as many close calls will have to be issued to close the ObjectContainer.
This behavior was changed since db4o version 6.1: only the first call against a file can be successful. Subsequent calls that request to open a database file that is already open will get a DatabaseFileLockedException. This behavior is much more intuitive and allows to simplify the internal db4o design as well.
ObjectContainer interface gives you all the basic functionality to work with persistent objects. Normally you can save a new or updated object of any class using ObjectContainer#set(object)
Deletion is done with the following method:
c#: container.Delete(object)
VB: container.Delete(object)
Through ObjectContainer#get and ObjectContainer#query you get access to objects retrieval functionality.
Object Container Features
The characteristic features of an ObjectContainer are:
Basically ObjectContainer supplies functionality, which is enough for the most common usage of db4o database.
Additional db4o features are provided by an interface extending ObjectContainer - ExtObjectContainer.
The idea of splitting basic and advanced functionality between 2 interfaces is:
Every ObjectContainer object is also an ExtObjectContainer. You can cast it to ExtObjectContainer or you can use #ext() method to get to the advanced features.