2011-06-29 22 views

回答

0

我希望你有裏識別你的實體類(一些常用的方式,如公共基類,或實施接口)。然後你可以做一個反射查詢,如:

from t in typeof(Entity).Assembly.ExportedTypes 
where typeof(Entity).IsAssignableFrom(t) || t.GetInterfaces.Any(i => i == typeof(CommonInterface)) 
select t 

沒有編譯器在手,但這是一個寬泛的方向。

相關問題