使用EF6(非EFCore)如何实现操作同一个entity传递指定的表名,比如log_201901,log_201902,log_201903...
参考 Dynamic table names in Entity Framework linq:
var tableName = "Table1";
// Get proper return type.
Type returnType;
switch(tableName) {
case "Table1":
returnType = typeof(Table1EntityType);
break;
case "Table2":
returnType = typeof(Table2EntityType);
break;
}
var query = context.Set(returnType);
// Filter against "query" variable below...
var result = query.Where(...);