SubAvg.cs 933 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. namespace SqlSugar
  7. {
  8. public class SubAvg: ISubOperation
  9. {
  10. public bool HasWhere
  11. {
  12. get; set;
  13. }
  14. public string Name
  15. {
  16. get
  17. {
  18. return "Avg";
  19. }
  20. }
  21. public Expression Expression
  22. {
  23. get; set;
  24. }
  25. public int Sort
  26. {
  27. get
  28. {
  29. return 200;
  30. }
  31. }
  32. public ExpressionContext Context
  33. {
  34. get; set;
  35. }
  36. public string GetValue(Expression expression = null)
  37. {
  38. var exp = expression as MethodCallExpression;
  39. return "AVG(" + SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle) + ")";
  40. }
  41. }
  42. }