SubAsWithAttr.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using System.Linq;
  5. using System.Text;
  6. namespace SqlSugar
  7. {
  8. public class SubAsWithAttr : ISubOperation
  9. {
  10. public bool HasWhere
  11. {
  12. get; set;
  13. }
  14. public string Name
  15. {
  16. get
  17. {
  18. return "AsWithAttr";
  19. }
  20. }
  21. public Expression Expression
  22. {
  23. get; set;
  24. }
  25. public int Sort
  26. {
  27. get
  28. {
  29. return 200;
  30. }
  31. }
  32. public ExpressionContext Context
  33. {
  34. get; set;
  35. }
  36. public string GetValue(Expression expression = null)
  37. {
  38. var exp = expression as MethodCallExpression;
  39. var type = exp.Type.GetGenericArguments()[0];
  40. var db = this.Context.SugarContext.Context;
  41. var entityInfo= db.EntityMaintenance.GetEntityInfo(type);
  42. var tableName = entityInfo.DbTableName;
  43. var queryable= ((QueryableProvider<object>)(db.Queryable<object>()));
  44. var expString = queryable.GetTableName(entityInfo, tableName);
  45. return "$SubAs:" + expString;
  46. }
  47. }
  48. }