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.1 KiB

2 years ago
  1. using System.Linq;
  2. using System.Linq.Expressions;
  3. namespace SqlSugar
  4. {
  5. public class SubFromTable : ISubOperation
  6. {
  7. public string Name
  8. {
  9. get
  10. {
  11. return @"Subqueryable";
  12. }
  13. }
  14. public Expression Expression
  15. {
  16. get; set;
  17. }
  18. public int Sort
  19. {
  20. get
  21. {
  22. return 300;
  23. }
  24. }
  25. public ExpressionContext Context
  26. {
  27. get; set;
  28. }
  29. public string GetValue(Expression expression)
  30. {
  31. var exp = expression as MethodCallExpression;
  32. var resType = exp.Method.ReturnType;
  33. var entityType = resType.GetGenericArguments().First();
  34. var name = entityType.Name;
  35. if (this.Context.InitMappingInfo != null)
  36. {
  37. this.Context.InitMappingInfo(entityType);
  38. this.Context.RefreshMapping();
  39. }
  40. return "FROM " + this.Context.GetTranslationTableName(name, true);
  41. }
  42. }
  43. }