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.

69 lines
2.1 KiB

2 years ago
  1. namespace EntityBuilder
  2. {
  3. public class TypeHelper
  4. {
  5. public static string GetType(string type, bool isNull)
  6. {
  7. var newType = @"string";
  8. switch (type)
  9. {
  10. case @"varchar":
  11. case @"varchar2":
  12. case @"nvarchar":
  13. case @"char":
  14. {
  15. newType = @"string";
  16. break;
  17. }
  18. case @"int":
  19. case @"integer":
  20. case @"bit":
  21. case @"smallint":
  22. {
  23. newType = @"int";
  24. if (isNull) newType = newType + @"?";
  25. break;
  26. }
  27. case @"long":
  28. case @"bigint":
  29. {
  30. newType = @"long";
  31. if (isNull) newType = newType + @"?";
  32. break;
  33. }
  34. case @"date":
  35. case @"datetime":
  36. case @"datetime2":
  37. case @"datetimeoffset":
  38. {
  39. newType = @"DateTime";
  40. if (isNull) newType = newType + @"?";
  41. break;
  42. }
  43. case @"decimal":
  44. case @"number":
  45. case @"money":
  46. case @"numeric":
  47. {
  48. newType = @"Decimal";
  49. if (isNull) newType = newType + @"?";
  50. break;
  51. }
  52. case @"double":
  53. {
  54. newType = @"double";
  55. if (isNull) newType = newType + @"?";
  56. break;
  57. }
  58. case @"float":
  59. {
  60. newType = @"float";
  61. if (isNull) newType = newType + @"?";
  62. break;
  63. }
  64. }
  65. return newType;
  66. }
  67. }
  68. }