我的类有一个外部DLL,我想根据类型进行查询。我解释得更好。
我得到了GetType函数的类型:
Type targetType = Type.GetType("...");
如果有任何方式可以选择这样的选择:
_context.Set<targetType>().ToList()
假设_context是我的DBContext。
由于
答案 0 :(得分:1)
确实有:
{{1}}
答案 1 :(得分:0)
我做了类似的事 这是一个例子
Public class repository: dbcontext
{
public IDbset<car> Cras {get; set;}
Public IQueryable<T> Get<T>()
{
return this.gettype().getproberties().find(x=>. x.propertytype== typeof(T)). Getvalue(this) as IQueryable<T>;
}
}
跳这个让你开始吧。 从moble写的:)