Domanda

Is there any way to tell db4o to call class default constructor while activating objects? I tried following code but it didn't work:

    private static void ConfigureDatabase()
    {
        var config = Db4oEmbedded.NewConfiguration();
        config.Common.ObjectClass(typeof(Device)).CallConstructor(true);
        using(var db = Db4oEmbedded.OpenFile(config, Helper.GetDataFilePath("index"))) { }
    }

The constructor of Device is never called when retrieving objects from database.

and here's how Device constructor looks like:

    public Device()
    {
        connectionType = ConnectionType.Disconnected;
    }

Any help would be appreciated.

UPDATE BWT, I also wanted to know if it's possible to tell db4o to call constructor for every objects, without having to write one by one for each type.

È stato utile?

Soluzione

Did you try this?

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.CallConstructors = true;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top