0
我想要獲得所有以「Foo」開頭的ObjectSet。我已經編寫了下面的代碼,但它並沒有進入if結構。比較泛型類型的運行時類型
foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(context))
{
if (prop.PropertyType == typeof(ObjectSet<>))
{
// It doesn't step here even though
// prop.PropertyType is an ObjectSet`1...
請幫忙。
非常感謝。 –
我會怎麼說:'prop.GetValue(context)as ObjectSet <>'? –
@ WaterCoolerv2:恐怕你不會。之後你想用它做什麼?你可以將它轉換爲ObjectQuery,或者使用反射或動態輸入來調用方法。 –