using System; using System.Collections; using BP.DA; namespace BP.En { /// /// EntityOIDNameAttr /// public class EntityOIDNameAttr:EntityOIDAttr { /// /// 名称 /// public const string Name="Name"; } /// /// 用于 OID Name 属性的实体继承。 /// abstract public class EntityOIDName : EntityOID { #region 构造 /// /// 主键值 /// public override string PK { get { return "OID"; } } public override string PKField { get { return "OID"; } } /// /// 构造 /// protected EntityOIDName() { } /// /// 构造 /// /// OID protected EntityOIDName(int oid) : base(oid) { } #endregion #region 属性方法 /// /// 名称 /// public string Name { get { return this.GetValStringByKey(EntityOIDNameAttr.Name); } set { this.SetValByKey(EntityOIDNameAttr.Name, value); } } /// /// 按照名称查询。 /// /// 返回查询出来的个数 public int RetrieveByName() { QueryObject qo = new QueryObject(this); qo.AddWhere("Name", this.Name); return qo.DoQuery(); } protected int LoadDir(string dir) { return 1; } protected override bool beforeUpdate() { if (this.EnMap.IsAllowRepeatName == false) { if (this.PKCount == 1) { if (this.ExitsValueNum("Name", this.Name) >= 2) throw new Exception("@更新失败[" + this.EnMap.EnDesc + "] OID=[" + this.OID + "]名称[" + Name + "]重复."); } } return base.beforeUpdate(); } #endregion } /// /// 用于OID Name 属性的实体继承 /// abstract public class EntitiesOIDName : EntitiesOID { #region 构造 /// /// 构造 /// public EntitiesOIDName() { // // TODO: 在此处添加构造函数逻辑 // } #endregion } }