문제

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.

도움이 되었습니까?

해결책

Did you try this?

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.CallConstructors = true;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top