IQueryable OfType where T is a runtime Type

后端 未结 7 624
旧巷少年郎
旧巷少年郎 2020-12-14 01:52

I need to be able to get something similar to the following to work:

Type type = ??? // something decided at runtime with .GetType or typeof;
object[] entity         


        
7条回答
  •  误落风尘
    2020-12-14 02:52

    Resource[] entityList = context.Resources
                                  .Where(t => t.GetType() == typeof(HumanResource))
                                  .ToArray();
    

提交回复
热议问题