jeudi 4 juin 2020

Reflection within IQueryable in .NET Core

I am wondering how would the below code work and what would be the performance. I am interested in line #4 basically. How will linq and property info work together?

In other words will (int)prop.GetValue(a) and a.SomeId work the same way or will the reflection need to get everything to memory before checking the value?

var prop = type.GetProperty("SomeId");

if (prop != null) 
{
     DbSet<T> dbSet = _dbContext.Set<T>();
     return dbSet.Where(a => (int)prop.GetValue(a) == 1);
}




Aucun commentaire:

Enregistrer un commentaire