1

似乎 db4o 将忽略配置参数,当您尝试索引从另一个对象继承的对象上的字段时。例如,如果我有以下内容:

public class foo
{
    private int theId;
    public int TheId {get{return theId;}set{theId=value;}}
}

public class bar:foo
{
    private string name;
    public string Name{get{return name;}set{name=value;}}
}

我的配置可能类似于:

IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(foo)).ObjectField("theId").Indexed(true);

这将起作用。但是,如果我尝试这样做:

IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(bar)).ObjectField("theId").Indexed(true);

配置被忽略;bar. TheId未编入索引。

我可以看到为什么这可能是设计的,但我找不到引用此行为的文档,或者将其视为可能的“陷阱”。那么这是一个错误,还是设计使然?在我看来,很多时候您可能只想在特定子类上索引该字段。

4

1 回答 1

2

我认为这是设计使然。您只能在声明它的类上索引字段。这也适用于所有子类。

Afaik, indexing a inherited field only on a subclass is not possible right now.

Added a documentation task for this.

于 2012-08-16T01:41:07.287 回答