日期:2014-05-17 浏览次数:20563 次
namespace XFramework.Model
{
[Serializable]
public partial class news: IModelCommon
{
public const int CASE_TYPE_NEWS_CLASS_ID = -1;
public delegate string GetNewsClassName(int classID);
public delegate string GetBrandName(int brandID);
public GetNewsClassName OnGetNewsClassName;
public GetBrandName OnGetBrandName;
private string _newsClass = null;
private string _brandName = null;
#region IModelCommon 成员
public int ID
{
get
{
return this.news_id;
}
set
{
this._news_id = value;
}
}
#endregion
public string NewsClass
{
get
{
if (!string.IsNullOrEmpty(this._newsClass))
{
return _newsClass;
}
if (OnGetNewsClassName != null)
{
_newsClass = OnGetNewsClassName(this._news_class.GetValueOrDefault());//这边通过委托回调给newsClass赋值,这个回调方法其实是在业务层里面的,方便写可以直接用lambda
OnGetNewsClassName = null;//手动把委托设置为null以便垃圾收集
return _newsClass;
}
return string.Empty;
}
}
}
}
------解决方案--------------------
其实、看你怎么用吧。你觉得限制了UI层的使用、但是我觉得实体类还是很重要的。就像他们说的学生类、你可以在new一个学生的时候、传一个学生的ID、然后通过学生就能拿到你想要的其他属性。还是很方便的吧。