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

时间:2012-08-23 12:49:44

标签: c# arraylist db4o

我有这个问题,我有一个类的属性是一个ArrayList,然后将该类存储在db4o容器中,在重新启动服务器后清除列表。

具有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; }
}

将类填充并存储到DB

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

    Database.Store(planet);
}

只要服务器正在运行,一切正常,列表是正确的,其中的值是正确的。班上的其他属性也是正确的。

重新启动服务器并清除列表。虽然类的其余部分仍然正确,并且数据库中的其他所有内容都很好,但只有列表因某种原因被清除。

有没有人知道为什么会发生这种情况?

1 个答案:

答案 0 :(得分:0)

Database.Store(行星);

这是商店还是更新?我的意思是,在设置“Moons”成员之前已经从db检索了“planet”对象,或者它是一个新实例化的obj?

您是否尝试使用简单的嵌入式应用程序?

相关问题