I am trying to reorganize a query that currently uses reflection:
var dbObjects = from d in collection where d.GetType().GetProperty("Id").GetValue(d, null) == id select d;
I would like to use dynamic typing to access the property identifier on "d", not knowing what type of "d" is at compile time. Something like that:
var dbObjects = from (dynamic)d in collection where d.Id == id select d;
Is it possible? ... and out of interest, is it faster or does dynamic runtime use reflection under the hood?
Thanks,
Alan
source share