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.

59 lines
3.9 KiB

2 years ago
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. namespace SqlSugar
  4. {
  5. public class SqlServerDbBind : DbBindProvider
  6. {
  7. public override List<KeyValuePair<string, CSharpDataType>> MappingTypes
  8. {
  9. get
  10. {
  11. var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices;
  12. if (extService != null&& extService.AppendDataReaderTypeMappings.HasValue())
  13. {
  14. return extService.AppendDataReaderTypeMappings.Union(MappingTypesConst).ToList();
  15. }
  16. else
  17. {
  18. return MappingTypesConst;
  19. }
  20. }
  21. }
  22. public static List<KeyValuePair<string, CSharpDataType>> MappingTypesConst = new List<KeyValuePair<string, CSharpDataType>>
  23. {
  24. new KeyValuePair<string, CSharpDataType>("int",CSharpDataType.@int),
  25. new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@string),
  26. new KeyValuePair<string, CSharpDataType>("nvarchar",CSharpDataType.@string),
  27. new KeyValuePair<string, CSharpDataType>("sql_variant",CSharpDataType.@string),
  28. new KeyValuePair<string, CSharpDataType>("text",CSharpDataType.@string),
  29. new KeyValuePair<string, CSharpDataType>("char",CSharpDataType.@string),
  30. new KeyValuePair<string, CSharpDataType>("ntext",CSharpDataType.@string),
  31. new KeyValuePair<string, CSharpDataType>("nchar",CSharpDataType.@string),
  32. new KeyValuePair<string, CSharpDataType>("hierarchyid",CSharpDataType.@string),
  33. new KeyValuePair<string, CSharpDataType>("bigint",CSharpDataType.@long),
  34. new KeyValuePair<string, CSharpDataType>("bit",CSharpDataType.@bool),
  35. new KeyValuePair<string, CSharpDataType>("datetime",CSharpDataType.DateTime),
  36. new KeyValuePair<string, CSharpDataType>("time",CSharpDataType.DateTime),
  37. new KeyValuePair<string, CSharpDataType>("smalldatetime",CSharpDataType.DateTime),
  38. new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.byteArray),
  39. new KeyValuePair<string, CSharpDataType>("datetime2",CSharpDataType.DateTime),
  40. new KeyValuePair<string, CSharpDataType>("date",CSharpDataType.DateTime),
  41. new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.@decimal),
  42. new KeyValuePair<string, CSharpDataType>("single",CSharpDataType.@decimal),
  43. new KeyValuePair<string, CSharpDataType>("money",CSharpDataType.@decimal),
  44. new KeyValuePair<string, CSharpDataType>("numeric",CSharpDataType.@decimal),
  45. new KeyValuePair<string, CSharpDataType>("smallmoney",CSharpDataType.@decimal),
  46. new KeyValuePair<string, CSharpDataType>("float",CSharpDataType.@double),
  47. new KeyValuePair<string, CSharpDataType>("float",CSharpDataType.Single),
  48. new KeyValuePair<string, CSharpDataType>("real",CSharpDataType.@float),
  49. new KeyValuePair<string, CSharpDataType>("smallint",CSharpDataType.@short),
  50. new KeyValuePair<string, CSharpDataType>("tinyint",CSharpDataType.@byte),
  51. new KeyValuePair<string, CSharpDataType>("uniqueidentifier",CSharpDataType.Guid),
  52. new KeyValuePair<string, CSharpDataType>("binary",CSharpDataType.byteArray),
  53. new KeyValuePair<string, CSharpDataType>("image",CSharpDataType.byteArray),
  54. new KeyValuePair<string, CSharpDataType>("varbinary",CSharpDataType.byteArray),
  55. new KeyValuePair<string, CSharpDataType>("datetimeoffset", CSharpDataType.DateTimeOffset),
  56. new KeyValuePair<string, CSharpDataType>("datetimeoffset", CSharpDataType.DateTime)};
  57. };
  58. }