【发布时间】:2019-03-09 07:50:20
【问题描述】:
string tableName = "TblStudents";
Dictionary<string, Type> myDictionary = new Dictionary<string, Type>()
{
{ "TblStudents", typeof(TblStudent) },
{ "TblTeachers", typeof(TblTeacher) }
};
// Context always same
DBContext dbContext = new DBContext();
DbSet dbSet = dbContext.Set(myDictionary[tableName]);
上面的代码来自这个post,我可以在其中动态地DbSet。如何在 Entity Framework Core 中完成这项工作?
我收到一个错误
DbSet dbSet = dbContext.Set(myDictionary[tableName]);
似乎Set 方法在新版本中已更改。
感谢您的帮助。
【问题讨论】:
标签: c# entity-framework-core dbset