0
我正在研究一个基于核心实体生成视图模型的T4模板。 比如我有核心新闻类,我想这个模板来生成视图模型,如这些在mvc4中读取类属性T4模板
public class News
{
public property int Id {get;set;}
public property string Title {get;set;}
public property string Content {get;set;}
}
public class NewsCreate
{
public property int Id {get;set;}
public property string Title {get;set;}
public property string Content {get;set;}
}
public class NewsUpdate
{
public property int Id {get;set;}
public property string Title {get;set;}
public property string Content {get;set;}
}
现在只是这两个。但我找不到获得News类属性的方法。我如何使用反射来获取它们。 。 。
供参考;还有roslyn,它可以为此使用text =>语法树转换。您也可以在T4中定义新闻的模型,并从中避免使用外部工具或反射来生成所有变体。 – FuleSnabel