JoinSql.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Ant.ORM
  6. {
  7. public class JoinSql
  8. {
  9. /// <summary>
  10. /// Gets the join type value.
  11. /// </summary>
  12. /// <param name="j">The j.</param>
  13. /// <returns></returns>
  14. public static string GetJoinTypeValue(JoinTypes j)
  15. {
  16. switch (j)
  17. {
  18. case JoinTypes.Outer:
  19. return " OUTER JOIN ";
  20. case JoinTypes.LeftInner:
  21. return " LEFT INNER JOIN ";
  22. case JoinTypes.LeftJoin:
  23. return " LEFT JOIN ";
  24. case JoinTypes.LeftOuter:
  25. return " LEFT OUTER JOIN ";
  26. case JoinTypes.RightJoin:
  27. return " RIGHT JOIN ";
  28. case JoinTypes.RightInner:
  29. return " RIGHT INNER JOIN ";
  30. case JoinTypes.RightOuter:
  31. return " RIGHT OUTER JOIN ";
  32. case JoinTypes.Cross:
  33. return " CROSS JOIN ";
  34. case JoinTypes.NotEqual:
  35. return " JOIN ";
  36. }
  37. return " INNER JOIN ";
  38. }
  39. }
  40. #region 操作符
  41. public class QueryOperator
  42. {
  43. /// <summary>
  44. /// Gets the comparison operator.
  45. /// </summary>
  46. /// <param name="comp">The comp.</param>
  47. /// <returns></returns>
  48. public static string GetComparisonOperator(Comparison comp)
  49. {
  50. switch (comp)
  51. {
  52. case Comparison.NotEquals:
  53. return " <> ";
  54. case Comparison.Like:
  55. return " LIKE ";
  56. case Comparison.NotLike:
  57. return " NOT LIKE ";
  58. case Comparison.GreaterThan:
  59. return " > ";
  60. case Comparison.GreaterOrEquals:
  61. return " >= ";
  62. case Comparison.LessThan:
  63. return " < ";
  64. case Comparison.LessOrEquals:
  65. return " <= ";
  66. case Comparison.Blank:
  67. return " ";
  68. case Comparison.Is:
  69. return " IS ";
  70. case Comparison.IsNot:
  71. return " IS NOT ";
  72. case Comparison.In:
  73. return " IN ";
  74. case Comparison.NotIn:
  75. return " NOT IN ";
  76. }
  77. return " = ";
  78. }
  79. /// <summary>
  80. ///
  81. /// </summary>
  82. /// <param name="op"></param>
  83. /// <returns></returns>
  84. public static string GetOperator(Operator op)
  85. {
  86. if (op == Operator.EqualLarger)
  87. return ">=";
  88. else if (op == Operator.Equal)
  89. return "=";
  90. else if (op == Operator.EqualSmaller)
  91. return "<=";
  92. else if (op == Operator.Smaller)
  93. return "<";
  94. else if (op == Operator.NotEqual)
  95. return "!=";
  96. else if (op == Operator.Larger)
  97. return ">";
  98. else if (op == Operator.Like)
  99. return "like";
  100. return string.Empty;
  101. }
  102. }
  103. #endregion
  104. }