You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. using Apewer;
  2. using Apewer.Internals;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Reflection;
  7. namespace Apewer.Source
  8. {
  9. /// <summary>数据库记录通用字段模型。</summary>
  10. /// <remarks>带有 Independent 特性的模型不包含此类型声明的属性。</remarks>
  11. [Serializable]
  12. public abstract class Record : IRecord
  13. {
  14. /// <summary>记录主键,一般使用 GUID 的字符串形式。</summary>
  15. /// <remarks>
  16. /// <para>注:</para>
  17. /// <para>1. 默认长度为 32,需要修改长度时应该重写此属性;</para>
  18. /// <para>2. 带有 Independent 特性的模型不包含此属性。</para>
  19. /// </remarks>
  20. [Column("_key", ColumnType.NVarChar, 32)]
  21. public virtual string Key { get; set; }
  22. /// <summary>记录的标记,Int64 类型,区分记录的状态。</summary>
  23. /// <remarks>带有 Independent 特性的模型不包含此属性。</remarks>
  24. [Column("_flag", ColumnType.Integer)]
  25. public virtual long Flag { get; set; }
  26. /// <summary>重置 Key 属性的值。</summary>
  27. public virtual void ResetKey() => Key = TextUtility.Key();
  28. /// <summary></summary>
  29. public Record()
  30. {
  31. ResetKey();
  32. Flag = DefaultFlag;
  33. }
  34. #region static
  35. /// <summary>创建 Record 对象时的默认 Flag 值。</summary>
  36. public static long DefaultFlag { get; set; }
  37. #endregion
  38. #region 运算符。
  39. /// <summary>从 Record 到 Boolean 的隐式转换,判断 Record 对象不为 NULL。</summary>
  40. public static implicit operator bool(Record instance) => instance != null;
  41. #endregion
  42. }
  43. }