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.

56 lines
2.2 KiB

2 years ago
  1. using System.Linq.Expressions;
  2. namespace SqlSugar
  3. {
  4. public class NewArrayExpessionResolve : BaseResolve
  5. {
  6. public NewArrayExpessionResolve(ExpressionParameter parameter) : base(parameter)
  7. {
  8. var expression = (NewArrayExpression)base.Expression;
  9. switch (base.Context.ResolveType)
  10. {
  11. case ResolveExpressType.WhereSingle:
  12. case ResolveExpressType.WhereMultiple:
  13. case ResolveExpressType.SelectSingle:
  14. case ResolveExpressType.SelectMultiple:
  15. case ResolveExpressType.FieldSingle:
  16. case ResolveExpressType.FieldMultiple:
  17. Check.ThrowNotSupportedException("NewArrayExpression");
  18. break;
  19. case ResolveExpressType.ArraySingle:
  20. foreach (var item in expression.Expressions)
  21. {
  22. base.Expression = item;
  23. base.Start();
  24. }
  25. break;
  26. case ResolveExpressType.Join:
  27. base.Context.ResolveType = ResolveExpressType.WhereMultiple;
  28. var i = 0;
  29. foreach (var item in expression.Expressions)
  30. {
  31. if (item is UnaryExpression)
  32. {
  33. base.Expression = item;
  34. base.Start();
  35. if (parameter.CommonTempData is JoinType)
  36. {
  37. if (i > 0)
  38. {
  39. base.Context.Result.Append("," + parameter.CommonTempData.ObjToString() + ",");
  40. }
  41. else
  42. {
  43. base.Context.Result.Append(parameter.CommonTempData.ObjToString() + ",");
  44. }
  45. ++i;
  46. }
  47. }
  48. }
  49. break;
  50. default:
  51. break;
  52. }
  53. }
  54. }
  55. }