lundi 24 juillet 2023

How can I use `ThenInclude` in generic class in UnitOfWork

I have generic Repository in my project.

I want to use ThenInclude() in Search method of unitofwork

how can i do it?

I use this method but ThenInclude does not work

 public async Task<IEnumerable<TEntity>> FindByConditionAsync(
                                         Expression<Func<TEntity, bool>> filter = null,                                              
                                         Func<IQueryable<TEntity>,IOrderedQueryable<TEntity>> orderBy = null, 
                                         params Expression<Func<TEntity, object>>[] includes)
 {
     IQueryable<TEntity> query = dbSet;
     foreach (var includ in includes)
     {
         query = query.Include(includ);
     }

     if (filter != null)
     {
         query = query.Where(filter);
     }

     if (orderBy != null)
     {
         query = orderBy(query);
     }

     return await query.ToListAsync();
 }

Aucun commentaire:

Enregistrer un commentaire