mardi 1 novembre 2016

Performance issue with Reflection.

I am trying to make a Dynamic search for EF Core. I made the whole thing in a loop like this:

foreach (var i in vm.SearchProperties)
{
  if (result == null)
    result = db.MyTable.Where(x => x.GetType().GetProperty(i).GetValue(x, null).ToString().ToLower().StartsWith("MySearchString"));
  else
    result = result.Where(x => x.GetType().GetProperty(i).GetValue(x,null).ToString().ToLower().StartsWith(i.Suchfeld.ToLower(“mySearchString”)));
}

After I added the reflection part it runs pretty fast. As soon I added the Reflection to it, it got slowed down by a factor of 1000. Any ideas how I get it speeded up or around the reflection part.





Aucun commentaire:

Enregistrer un commentaire