简体   繁体   English

重新启动后将对象列表存储在db4o中清除

[英]Store a list of objects in db4o clears after restart

I have this issue where I have a property of a class which is an ArrayList, and then storeing this class in a db4o container clears the list after a restart of the server. 我有一个问题,我有一个属于ArrayList的类的属性,然后将该类存储在db4o容器中会在服务器重新启动后清除该列表。

Class that has the ArrayList property looks somewhat like this: 具有ArrayList属性的类看起来像这样:

public class Planet
{
    public string Name { get; set; }
    public string Identifier { get; set; }

    // Planet has an ArrayList property called Moons.
    public ArrayList Moons { get; set; }
}

Populating and storeing the class to the DB 将类填充并存储到数据库

if (planet.Moons == null)
{
    planet.Moons = new ArrayList();
    planet.Moons.Add(new Moon("MoonOne"));
    planet.Moons.Add(new Moon("MoonTwo"));

    Database.Store(planet);
}

As long as the server is running everything works fine, the list is correct and the values inside it are correct. 只要服务器正在运行,一切正常,列表是正确的,并且其中的值是正确的。 The other propertys of the class are also correct and fine. 该类的其他属性也是正确的。

Restarting the server and the list clears. 重新启动服务器,列表将清除。 Though the rest of the class is still correct, and everything else in the database is fine, only the list gets cleared for some reason. 尽管该类的其余部分仍然正确,并且数据库中的其他所有内容都很好,但是出于某种原因,仅清除了该列表。

Does anyone have any clue to why this might be happening? 有谁知道为什么会这样吗?

Database.Store(planet); Database.Store(planet);

Is this a store or an update? 这是商店还是更新? I mean, "planet" object has been retrieved from db prior to setting "Moons" member or is it a newly instantiated obj? 我的意思是,在设置“ Moons”成员之前,已经从db中检索了“ planet”对象,或者它是新实例化的obj?

Have you tried it with a simple embedded app ? 您是否尝试过使用简单的嵌入式应用程序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM