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.

57 lines
1.1 KiB

2 years ago
  1. using System.Linq.Expressions;
  2. namespace SqlSugar
  3. {
  4. public class SubTop : ISubOperation
  5. {
  6. public ExpressionContext Context
  7. {
  8. get; set;
  9. }
  10. public Expression Expression
  11. {
  12. get; set;
  13. }
  14. public string Name
  15. {
  16. get
  17. {
  18. return "Top";
  19. }
  20. }
  21. public int Sort
  22. {
  23. get
  24. {
  25. if (this.Context is SqlServerExpressionContext)
  26. {
  27. return 150;
  28. }
  29. else
  30. {
  31. return 490;
  32. }
  33. }
  34. }
  35. public string GetValue(Expression expression)
  36. {
  37. if (this.Context is SqlServerExpressionContext)
  38. {
  39. return "TOP 1";
  40. }
  41. else if (this.Context is OracleExpressionContext)
  42. {
  43. return "ROWNUM=1";
  44. }
  45. else
  46. {
  47. return "limit 0,1";
  48. }
  49. }
  50. }
  51. }