【发布时间】:2010-02-01 19:21:33
【问题描述】:
我正在做一个小应用程序来帮助我平衡我的支票簿。 我正在使用 Castle ActiveRecord 将对象属性映射到数据库。现在这是问题所在。当我在做一个赚钱程序时,我做了一个结构货币
结构:
public struct Currency
{
private long amount;
private CurrencyType currencyType;
public long Amount
{
get { return this.amount; }
set { this.amount = value; }
}
public CurrencyType CurrencyType
{
get { return this.currencyType; }
set { this.currencyType = value; }
}
}
我正在映射的类:
[ActiveRecord("[Transaction]")]
public class Transaction: HasOwnerModelBase
{
private Currency amount;
private Category category;
[BelongsTo]
public virtual Category Category
{
get { return this.category; }
set { this.category = value; }
}
public virtual Currency Amount
{
get { return this.amount; }
set { this.amount = value; }
}
}
现在,在理想情况下,Currency 对象的行为类似于嵌套对象,因此 amount 和 currencyType 是交易表中的两个列。 但它不是嵌套视图,因为我希望它像货币结构对象一样。
我不知道我应该给货币金额添加什么标签才能让它工作,如果有人能帮助我解决这个问题,我将不胜感激。
我希望这一切都清楚。
伟大的邓肯
【问题讨论】:
标签: c# struct nhibernate-mapping castle-activerecord