SqlFilter.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. namespace SqlSugar
  7. {
  8. public class SqlFilterItem
  9. {
  10. /// <summary>
  11. /// Equal to NULL representing global
  12. /// </summary>
  13. public string FilterName { get; set; }
  14. public Func<ISqlSugarClient,SqlFilterResult> FilterValue { get; set; }
  15. /// <summary>
  16. /// Is it a multiple table query?
  17. /// </summary>
  18. public bool IsJoinQuery { get; set; }
  19. internal Type type { get; set; }
  20. }
  21. public class TableFilterItem<T>: SqlFilterItem
  22. {
  23. private TableFilterItem()
  24. {
  25. }
  26. private Expression exp { get; set; }
  27. public TableFilterItem(Expression<Func<T,bool>> expression,bool isJoinOn=false)
  28. {
  29. exp = expression;
  30. type = typeof(T);
  31. base.IsJoinQuery = isJoinOn;
  32. this.IsJoinQuery = isJoinOn;
  33. }
  34. public TableFilterItem(Type entityType,Expression expression, bool isJoinOn=false)
  35. {
  36. exp = expression;
  37. type = entityType;
  38. base.IsJoinQuery = isJoinOn;
  39. this.IsJoinQuery = isJoinOn;
  40. }
  41. private new string FilterName { get; set; }
  42. private new Func<ISqlSugarClient, SqlFilterResult> FilterValue { get; set; }
  43. private new bool IsJoinQuery { get; set; }
  44. }
  45. public class SqlFilterResult
  46. {
  47. public string Sql { get; set; }
  48. public object Parameters { get; set; }
  49. }
  50. }