It depends :)
By default no, since db4o will try to avoid calling the ctor and field initializers are executed within the ctor) (at least using C# compiler shipped with VS 2010).
For example, given the following class definition:
public class Item
{
public object o = new object();
}
C# compiler will emit IL (for the constructor) similar to:
.class public auto ansi beforefieldinit Item extends [mscorlib]System.Object
{
.field public object o
.field public notserialized int32 i
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
.maxstack 8
ldarg.0
newobj instance void [mscorlib]System.Object::.ctor() // field initializer
stfld object Item::o // field initializer
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
Basically you have two options here:
- Enable constructor invocations
- Use Activated event to initialize the transient fields.
Hope this helps