【问题标题】:Store a list of objects in db4o clears after restart重新启动后将对象列表存储在 db4o 中
【发布时间】:2012-08-18 23:45:26
【问题描述】:

我有这个问题,我有一个类的属性,它是一个 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; }
}

将类填充并存储到数据库中

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

    Database.Store(planet);
}

只要服务器运行一切正常,列表是正确的,其中的值是正确的。该类的其他属性也正确无误。

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

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

【问题讨论】:

标签: c# arraylist db4o


【解决方案1】:

Database.Store(行星);

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    相关资源
    最近更新 更多