I have a calculated property in my object that I don't want to save to the DB, is there a way I can specify that?
Like this one as an exemple :
public virtual string 开发者_如何转开发FullInfos
{
get
{
var html = Contact1Info;
html += Contact2Info;
return html;
}
}
Where Contact1Info and Contact2Info are automatic property already saved...
Thanks!
NoRM provides a series of attributes. In this case you're looking for the [MongoIgnore]
attribute.
Should be as simple as
[MongoIgnore]
public virtual string FullInfos
{
get
{
var html = Contact1Info;
html += Contact2Info;
return html;
}
}
Convert it to a method, in which case NORM won't map it.
These kinds of "Properties" are better defined as methods anyways.. in the strict OO sense it shouldn't be viewed as a "Property" of the object if it is being calculated.
精彩评论