我的对象中有一个计算属性,我不想保存到DB,有没有办法可以指定?
像这个例子一样:
public virtual string FullInfos
{
get
{
var html = Contact1Info;
html += Contact2Info;
return html;
}
}
其中Contact1Info和Contact2Info是已保存的自动属性...
谢谢!
答案 0 :(得分:3)
NoRM提供了一系列属性。在这种情况下,您正在寻找[MongoIgnore]
属性。
应该像
一样简单[MongoIgnore]
public virtual string FullInfos
{
get
{
var html = Contact1Info;
html += Contact2Info;
return html;
}
}
答案 1 :(得分:0)
将其转换为方法,在这种情况下,NORM不会映射它。
这些“属性”更好地定义为方法..在严格的OO意义上,如果计算对象,它不应被视为对象的“属性”。