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.

49 lines
1.8 KiB

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