简体   繁体   English

db4o-忽略特定的类属性

[英]db4o - ignore specific class property

Is there a way (meta property maybe) to tell db4o to simply ignore a specific property of a class? 是否有一种方法(可能是meta属性)告诉db4o只是忽略类的特定属性?

I can't see anywhere to do that.. 我看不到任何地方可以这样做。

For my purpose I have a bunch of data entity that i need to persist now and then. 出于我的目的,我有一堆数据实体,我需要不时地坚持下去。 I also sometimes need to hold a ref to a UI element associated with it, but I don't want db4o to persist that element when I update the object. 有时我还需要保留对与其关联的UI元素的引用,但是我不希望db4o在更新对象时保留该元素。

I can go around it by backing up, nulling the ref, saving, and finally restoring the reference but it seems really bad. 我可以通过备份,使引用无效,保存并最终还原引用来解决它,但这似乎真的很糟糕。

Anyway I can tell db4o to ignore it altogether? 无论如何,我可以告诉db4o完全忽略它?

You can add the Transient attribute to the specific field (db4o knowns nothing about properties) 您可以将Transient属性添加到特定字段(db4o对属性一无所知)

public class Test
{
    [Transient] private string name;
    // ...
}

Best 最好

Its actually right there in the doco, you just need the right search term :-) 它实际上就位于doco中,您只需要正确的搜索词即可:-)

Look in the docs for Transient Fields / Classes. 在文档中查找“瞬态字段/类”。

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

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