DataFieldAttribute.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Text;
  5. namespace Ant.ORM
  6. {
  7. /// <summary>
  8. /// 字段标签
  9. /// </summary>
  10. [AttributeUsage(AttributeTargets.Property)]
  11. public class DataFieldColumnAttribute : Attribute
  12. {
  13. private string name;
  14. /// <summary>
  15. /// 列名
  16. /// </summary>
  17. public string Name
  18. {
  19. get { return name; }
  20. set { name = value; }
  21. }
  22. private DbType dbType;
  23. /// <summary>
  24. /// 类型
  25. /// </summary>
  26. public DbType DbType
  27. {
  28. get { return dbType; }
  29. set { dbType = value; }
  30. }
  31. private object defaultValue;
  32. /// <summary>
  33. /// 默认值
  34. /// </summary>
  35. public object DefaultValue
  36. {
  37. get { return defaultValue; }
  38. set { defaultValue = value; }
  39. }
  40. private bool isPrimaryKey = false;
  41. /// <summary>
  42. /// 是否为主键
  43. /// </summary>
  44. public bool IsPrimaryKey
  45. {
  46. get { return isPrimaryKey; }
  47. set { isPrimaryKey = value; }
  48. }
  49. private bool isForeignKey = false;
  50. /// <summary>
  51. /// 是否为外键
  52. /// </summary>
  53. public bool IsForeignKey
  54. {
  55. get { return isForeignKey; }
  56. set { isForeignKey = value; }
  57. }
  58. private bool isNullable = true;
  59. /// <summary>
  60. /// 是否为空
  61. /// </summary>
  62. public bool IsNullable
  63. {
  64. get { return isNullable; }
  65. set { isNullable = value; }
  66. }
  67. private bool isAutoincrement = false;
  68. /// <summary>
  69. /// 是否为自动增长
  70. /// </summary>
  71. public bool IsAutoincrement
  72. {
  73. get { return isAutoincrement; }
  74. set { isAutoincrement = value; }
  75. }
  76. public DataFieldColumnAttribute(string name, DbType dbType)
  77. {
  78. this.name = name;
  79. this.DbType = dbType;
  80. }
  81. }
  82. }