title: How to convert my predicate to a generic predicate in C#?
body: <p>I have a predicate code that works perfectly but I want to reduce my code and convert it to generic  and use it in my repository</p>
  <pre><code>public abstract class RequestParameters
  {
      const int maxPageSize = 5;
      public int PageNumber { get; set; } = 1;
  
      private int _pageSize = 10;
      public int PageSize
      {
          get
          {
              return _pageSize;
          }
          set
          {
              _pageSize = (value &gt; maxPageSize) ? maxPageSize : value;
          }
      }
      public string OrderBy { get; set; }
      public string Fields { get; set; }
  }
  </code></pre>
  <p>and this is my EmployeeSearchModel</p>
  <pre><code>public class EmployeeSearchModel : RequestParameters
  {
      public EmployeeSearchModel()
      {
      
          OrderBy = &quot;name&quot;;
      }       
  
      public string Name { get; set; }
      public int Age { get; set; }
      public string Position { get; set; }
  
      public Expression&lt;System.Func&lt;Employee, bool&gt;&gt; Go()
      {
          var predicate = PredicateBuilder.True&lt;Employee&gt;();
  
          if (!string.IsNullOrEmpty(Name))
          {
              predicate = predicate.And(i =&gt; i.Name.ToLower().Contains(Name.ToLower()));
          }
          if (!string.IsNullOrEmpty(Position))
          {
              predicate = predicate.And(i =&gt; i.Position.ToLower().Contains(Position.ToLower()));
          }
          return predicate;
      }
  }
  </code></pre>
  <p>and this is my Repository</p>
  <pre><code>public async Task&lt;PagedList&lt;Employee&gt;&gt; GetEmployeesAsyncExp(EmployeeSearchModel employeeParameters)
      {
          Expression f = employeeParameters.Go();
  
          var employees = await FindByCondition(employeeParameters.Go())
          .OrderBy(e =&gt; e.Name)           
          .ToListAsync()....
  </code></pre>
  <p>....</p>
  <p>and now I want to change it to generic somethings like this:</p>
  <pre><code>public class EmployeeSearchModel&lt;T&gt; : RequestParameters ...
  </code></pre>