ReferenceAttribute.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. namespace Ant.ORM
  6. {
  7. /// <summary>
  8. /// 引用对象的关系(扩展对象)
  9. /// </summary>
  10. [AttributeUsage(AttributeTargets.Property)]
  11. public class ReferenceAttribute : Attribute
  12. {
  13. private DbType[] _DataType;
  14. private string[] _ForeignKey;
  15. private string _ForeignTable;
  16. private string _Key;
  17. private string[] _MainKey;
  18. private string _ShowField;
  19. /// <summary>
  20. /// 扩展对象及关联对象
  21. /// </summary>
  22. /// <param name="key">关键字</param>
  23. /// <param name="maintable">主表</param>
  24. /// <param name="foreignTable">外键所在的表</param>
  25. /// <param name="mainKey">主表主键</param>
  26. /// <param name="foreignKey">外键关联的字段</param>
  27. /// <param name="dataType">数据类型</param>
  28. /// <param name="showField">显示字段</param>
  29. public ReferenceAttribute(string key, string foreignTable, string[] mainKey, string[] foreignKey, DbType[] dataType, string showField)
  30. {
  31. this._Key = key;
  32. this._ForeignTable = foreignTable;
  33. this._ForeignKey = foreignKey;
  34. this._MainKey = mainKey;
  35. this._DataType = dataType;
  36. this._ShowField = showField;
  37. }
  38. /// <summary>
  39. /// 数据类型
  40. /// </summary>
  41. public DbType[] DataType
  42. {
  43. get
  44. {
  45. return this._DataType;
  46. }
  47. }
  48. /// <summary>
  49. /// 外键
  50. /// </summary>
  51. public string[] ForeignKey
  52. {
  53. get
  54. {
  55. return this._ForeignKey;
  56. }
  57. }
  58. /// <summary>
  59. /// 外键所在的表
  60. /// </summary>
  61. public string ForeignTable
  62. {
  63. get
  64. {
  65. return this._ForeignTable;
  66. }
  67. }
  68. /// <summary>
  69. /// 关键字
  70. /// </summary>
  71. public string Key
  72. {
  73. get
  74. {
  75. return this._Key;
  76. }
  77. }
  78. /// <summary>
  79. /// 主键
  80. /// </summary>
  81. public string[] MainKey
  82. {
  83. get
  84. {
  85. return this._MainKey;
  86. }
  87. }
  88. /// <summary>
  89. /// 显示值的字段
  90. /// </summary>
  91. public string ShowField
  92. {
  93. get
  94. {
  95. return this._ShowField;
  96. }
  97. }
  98. }
  99. }