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.

48 lines
2.4 KiB

2 years ago
  1. using System.Collections.Generic;
  2. using System.Linq.Expressions;
  3. namespace SqlSugar
  4. {
  5. public class SubTools
  6. {
  7. public static List<ISubOperation> SubItems(ExpressionContext Context)
  8. {
  9. return new List<ISubOperation>
  10. {
  11. new SubSelect { Context=Context },
  12. new SubWhere{ Context=Context },
  13. new SubAnd{ Context=Context },
  14. new SubAny{ Context=Context },
  15. new SubNotAny{ Context=Context },
  16. new SubBegin{ Context=Context },
  17. new SubFromTable{ Context=Context },
  18. new SubCount{ Context=Context },
  19. new SubMax{ Context=Context },
  20. new SubMin{ Context=Context },
  21. new SubSum{ Context=Context },
  22. new SubAvg{ Context=Context },
  23. new SubOrderBy{ Context=Context },
  24. new SubOrderByDesc{ Context=Context },
  25. new SubGroupBy{ Context=Context}
  26. };
  27. }
  28. public static List<ISubOperation> SubItemsConst = SubItems(null);
  29. public static string GetMethodValue(ExpressionContext context, Expression item, ResolveExpressType type)
  30. {
  31. var newContext = context.GetCopyContext();
  32. newContext.MappingColumns = context.MappingColumns;
  33. newContext.MappingTables = context.MappingTables;
  34. newContext.IgnoreComumnList = context.IgnoreComumnList;
  35. newContext.SqlFuncServices = context.SqlFuncServices;
  36. newContext.Resolve(item, type);
  37. context.Index = newContext.Index;
  38. context.ParameterIndex = newContext.ParameterIndex;
  39. if (newContext.Parameters.HasValue())
  40. context.Parameters.AddRange(newContext.Parameters);
  41. return newContext.Result.GetResultString();
  42. }
  43. }
  44. }