SubHaving.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. namespace SqlSugar
  8. {
  9. public class SubHaving : ISubOperation
  10. {
  11. public bool HasWhere
  12. {
  13. get; set;
  14. }
  15. public string Name
  16. {
  17. get { return "Having"; }
  18. }
  19. public Expression Expression
  20. {
  21. get; set;
  22. }
  23. public int Sort
  24. {
  25. get
  26. {
  27. return 480;
  28. }
  29. }
  30. public ExpressionContext Context
  31. {
  32. get; set;
  33. }
  34. public string GetValue(Expression expression)
  35. {
  36. var exp = expression as MethodCallExpression;
  37. var argExp = exp.Arguments[0];
  38. var result = "Having " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
  39. var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
  40. if (this.Context.JoinIndex == 0)
  41. result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
  42. return result;
  43. }
  44. }
  45. }