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.

50 lines
1.2 KiB

4 years ago
4 years ago
4 years ago
  1. using Apewer.Internals;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace Apewer.Source
  6. {
  7. /// <summary>数据库中的表。</summary>
  8. [Serializable]
  9. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
  10. public sealed class TableAttribute : Attribute
  11. {
  12. private string _name;
  13. private bool _independent = false;
  14. /// <summary></summary>
  15. public TableAttribute(string name = null)
  16. {
  17. _name = TableStructure.RestrictName(name, string.IsNullOrEmpty(name));
  18. }
  19. /// <summary></summary>
  20. internal TableAttribute(string name, bool underline)
  21. {
  22. _name = TableStructure.RestrictName(name, underline);
  23. }
  24. /// <summary>表名。</summary>
  25. public string Name
  26. {
  27. get => _name;
  28. set => _name = TableStructure.RestrictName(value, false);
  29. }
  30. /// <summary></summary>
  31. public bool Independent
  32. {
  33. get => _independent;
  34. internal set => _independent = value;
  35. }
  36. /// <summary></summary>
  37. public override int GetHashCode() => _name.GetHashCode();
  38. }
  39. }