MongoDbFieldAttribute.cs 971 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Ant.Service.Mongodb
  7. {
  8. /// <summary>
  9. /// Mongodb数据库的字段特性 主要是设置索引之用
  10. /// </summary>
  11. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
  12. public class MongoDbFieldAttribute : Attribute
  13. {
  14. /// <summary>
  15. /// 是否是索引
  16. /// </summary>
  17. public bool IsIndex { get; set; }
  18. /// <summary>
  19. /// 是否是唯一的 默认flase
  20. /// </summary>
  21. public bool Unique { get; set; }
  22. /// <summary>
  23. /// 是否是升序 默认true
  24. /// </summary>
  25. public bool Ascending { get; set; }
  26. public MongoDbFieldAttribute(bool _isIndex)
  27. {
  28. this.IsIndex = _isIndex;
  29. this.Unique = false;
  30. this.Ascending = true;
  31. }
  32. }
  33. }