SplitTableAttribute.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace SqlSugar
  7. {
  8. [AttributeUsage(AttributeTargets.Class, Inherited = true)]
  9. public class SplitTableAttribute : Attribute
  10. {
  11. public SplitType SplitType { get; set; }
  12. public Type CustomSplitTableService { get; set; }
  13. public SplitTableAttribute(SplitType splitType)
  14. {
  15. this.SplitType = splitType;
  16. }
  17. public SplitTableAttribute(SplitType splitType,Type customSplitTableService)
  18. {
  19. this.SplitType = splitType;
  20. if (!customSplitTableService.GetInterfaces().Any(it => it == typeof(ISplitTableService)))
  21. {
  22. Check.ExceptionEasy("customSplitTableService in SplitTableAttribute(SplitType splitType,Type customSplitTableService) must be inherited ISplitTableService", " SplitTableAttribute(SplitType splitType,Type customSplitTableService) 中的 customSplitTableService 必须继承 ISplitTableService");
  23. }
  24. this.CustomSplitTableService= customSplitTableService;
  25. }
  26. }
  27. [AttributeUsage(AttributeTargets.Property, Inherited = true)]
  28. public class SplitFieldAttribute : Attribute
  29. {
  30. public SplitFieldAttribute()
  31. {
  32. }
  33. }
  34. [AttributeUsage(AttributeTargets.Property, Inherited = true)]
  35. public class TimeDbSplitFieldAttribute : Attribute
  36. {
  37. public DateType? DateType { get; set; }
  38. public TimeDbSplitFieldAttribute(DateType type)
  39. {
  40. DateType = type;
  41. }
  42. }
  43. }