0

I am writing a general repository method like below:

public IEnumerable<T> GetEntities<T>(Func<T, bool> condition) 
{
     return _dbContext.Set<T>().AsQueryable<T>().Where(condition).ToList();
}

And on some BLL class I am trying to use the method like this:

var specificUsersNames = .. // List<string> of names
var users = _usersRepo.GetEntities<User>(x => specificUserNames.Contains(x.Name));

After seeing the logs in the console, here's the generated SQL:

SELECT [u].[Id], [u].[Name], [u].[PhoneNr], [u].[Address]
FROM [User] AS [u]

I have tried using Any instead of Contains but I get the same result.

It is getting all the rows, but when debugging, it shows only the correct ones.

Any idea why I get this generated SQL?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Muhamed Krasniqi
  • 1,134
  • 1
  • 13
  • 20

0 Answers0