首先,对于如下代码的思考,对于一个Model类的代理做到不覆盖父类属性的处理方法的方式

public partial class Question
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _QuestionID;
private string _Name;
private EntitySet<Answer> _Answers;
public Question()
{
this._Answers = new EntitySet<Answer>(
new Action<Answer>(this.attach_Answers),
new Action<Answer>(this.detach_Answers));
}
public int QuestionID { ... }
public string Name { ... }
public EntitySet<Answer> Answers
{
get
{
return this._Answers;
}
set
{
this._Answers.Assign(value);
}
}
private void attach_Answers(Answer entity)
{
entity.Question = this;
}
private void detach_Answers(Answer entity)
{
entity.Question = null;
}
}
本文参考自:我对NHibernate的感受(3):有些尴尬的集合支持