我确实需要创建如下所示的内容,我正在构建 2 个类,第一个类是名称为 tableNameAsSingular (即 AddressEntity) 的类,在我的第二个工作类中,我需要具有如下所示的内容
public IEnumerable<AddressEntity> GetAddressEntity()
{
// the good stuff...
}
创建函数时我有以下内容..
Type t = Type.GetType("IEnumerable<" + tableNameAsSingular + ">");
CodeFunction2 finderFunction = (CodeFunction2)entityServiceClass.AddFunction("Get" + table.Name, vsCMFunction.vsCMFunctionFunction, t, -1, vsCMAccess.vsCMAccessPublic, null);
但 t 始终为空
当我做Type.GetType(tableNameAsSingular)
它也返回 null
任何帮助或指示将不胜感激。另外,如果有人知道大量的 EnvDTE 代码生成知识在哪里,我将非常感激!
Update
我现在已经使用以下命令将其作为字符串进行了尝试:
public void AddFinderMethod()
{
string t = "IEnumerable<" + tableNameAsSingular + ">";
CodeFunction2 finderFunction = (CodeFunction2)entityServiceClass.AddFunction("Get" + table.Name, vsCMFunction.vsCMFunctionFunction, t, -1, vsCMAccess.vsCMAccessPublic, null);
// Code here remove as it does not get this far yet.
}
但我得到“IEnumerable<ProductEntity> is not a valid identifier
" AddFunction 方法中的错误消息