title: How to use 2 expressions in EF Repository Pattern
body: <p>I have this method in my Generic EF Repository class</p>
  <pre><code>public class GenericRepository&lt;T&gt; : IGenericRepository&lt;T&gt; where T : class
  {
      public async Task&lt;IEnumerable&lt;T&gt;&gt; GetAllByExpression&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; expression,
          Expression&lt;Func&lt;T, object&gt;&gt;[] includes) where T : class
      {
          if (expression != null)
          {
              IQueryable&lt;T&gt; query = context.Set&lt;T&gt;();
              foreach(var include in includes)
              {
                  query = query.Include(include);
              }
  
              var result = await query.Where(expression)
                  .ToListAsync();
  
              return result;
          }
          else
          {
              throw new ArgumentNullException(&quot;Invalid expression.&quot;);
          }
      }
  }
  </code></pre>
  <p>I do not know how to use the &quot;Include&quot; to it. Basically what I want to get is like this =&gt;</p>
  <pre><code>return await context.PropertyChargesRates.Where(x =&gt; x.BuildingId == buildingId)
                      .Include(x =&gt; x.PropertyChargeType)
                      .ToListAsync();
  </code></pre>
  <p>This is how I try to utilize this function:</p>
  <pre><code>public async Task&lt;IEnumerable&lt;PropertyChargesRate&gt;&gt; GetPropertyChargeRates(int buildingId)
          {
              try
              {
                  var g = new GenericRepository&lt;PropertyChargesRate&gt;(context);
                  var result = g.GetAllByExpression&lt;PropertyChargesRate&gt;(x =&gt; x.BuildingId == buildingId, ** CANT FIGURE OUT HOW TO CALL THIS PART YET **);
  
                  return result;
              }
              catch (Exception ex)
              {
                  return null;
              }
          }
  </code></pre>