namespace Common.Core { public abstract class BaseEntity { /// /// 判断主键是否为空,常用做判定操作是【添加】还是【编辑】 /// /// public abstract bool KeyIsNull(); /// /// 创建默认的主键值 /// public abstract void GenerateDefaultKeyVal(); public BaseEntity() { if (KeyIsNull()) { GenerateDefaultKeyVal(); } } } }