0
I have a class of App
where in that class contains a ICollection<Comentarios>
Now I need to filter ALL comments who have Status == Aprovado
, where this Status is an Enum.
I tried to do it this way:
IEnumerable<App> app = await GetAsync(
c => c.Comments.Where(d => d.Status == Status.Approved)
);
public async Task<IEnumerable<T>> GetAsync(Expression<Func<T, bool>> predicate)
{
return await _dbContext.Set<T>().Where(predicate).ToListAsync();
}
the error is returned:
Cannot implicitly Convert type 'System.Collections.Generic.Ienumerable<Showcase.Core.Entities.Comment>' to 'bool'
How is that method?
GetAsync
– Marconi
@Marconi public async Task<Ienumerable<T>> Getasync(Expression<Func<T, bool>> predicate) { Return await _dbContext.Set<T>(). Where(predicate). Tolistasync(); }
– Desalex
Only
await GetAsync(d => d.Status == Status.Approved);
doesn’t work?– Marconi