Hi folks
I'm trying to refactor 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 Id on "d" without knowing what type "d" is at compile time. Something like this:
var dbObjects = from (dynamic)d in collection
where d.Id == id
select d;
Is this possible? ... and out of interest, is it faster, or does the dynamic runtime use reflection under the hood?
Thanks,
Alan