我有以下课程,
public class DataManagementService<T> where T : class
{
public virtual List<string> getFields()
{
var colNames = typeof(T).GetProperties().Select(a => a.Name).ToList();
return colNames;
}
}
上述类返回特定表的列名(例如EMP_TAB)
class DataAccesAPI
{
public List<string> getFields(string tableName)
{
Type typeArgument = Type.GetType(tableName);
Type genericClass = typeof(DataManagementService<>);
Type constructedClass = genericClass.MakeGenericType(typeArgument);
object created = Activator.CreateInstance(constructedClass);
var activity = new DataManagementService<??????>();
return activity.getFields();
}
}
我已根据其他解决方案更新了代码,但我仍然无法将类型传递给调用其方法所需的DataanagementService?