我试图回答目前使用反思的提问:
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?
感谢
页: 1