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.

47 lines
1.7 KiB

2 years ago
  1. using System;
  2. using System.Linq.Expressions;
  3. namespace SqlSugar
  4. {
  5. public class MemberConstExpressionResolve : BaseResolve
  6. {
  7. public MemberConstExpressionResolve(ExpressionParameter parameter) : base(parameter)
  8. {
  9. var expression = base.Expression as MemberExpression;
  10. var isLeft = parameter.IsLeft;
  11. var value = ExpressionTool.GetMemberValue(expression.Member, expression);
  12. var baseParameter = parameter.BaseParameter;
  13. var isSetTempData = baseParameter.CommonTempData.HasValue() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);
  14. switch (parameter.Context.ResolveType)
  15. {
  16. case ResolveExpressType.Update:
  17. case ResolveExpressType.SelectSingle:
  18. case ResolveExpressType.SelectMultiple:
  19. if (value != null && value.GetType().IsEnum())
  20. {
  21. value = Convert.ToInt64(value);
  22. }
  23. parameter.BaseParameter.CommonTempData = value;
  24. break;
  25. case ResolveExpressType.WhereSingle:
  26. case ResolveExpressType.WhereMultiple:
  27. if (isSetTempData)
  28. {
  29. baseParameter.CommonTempData = value;
  30. }
  31. else
  32. {
  33. AppendValue(parameter, isLeft, value);
  34. }
  35. break;
  36. case ResolveExpressType.FieldSingle:
  37. case ResolveExpressType.FieldMultiple:
  38. break;
  39. default:
  40. break;
  41. }
  42. }
  43. }
  44. }