T4 Output to String

醉酒当歌 提交于 2019-12-22 11:29:08

问题


I am new to T4, I want to generate CRUD Stored Procedures, Data access layer, output to string, I am trying to create kind of webservice api to be useful to other programmers also, just input the data, and download zip file.

I have searched a lot but could not find a way to generate output to string, is it possible, any articles, links, a bit of code if possible would be helpful.

Yes, we can also use StringBuilder, but The question is "T4 Output to String" please all type of answers are welcome, but try to focus on the question.


回答1:


You can use preprocessed T4 templates to return a string instead of generating a file.

If you change the Custom Tools property on the file in Visual Studio to TextTemplatingFilePreprocessor then when you save the T4 template a class will be generated. This class will have a TransformText method which returns the generated text.

MSDN also has information on run-time text generation with preprocessed T4 templates.



来源:https://stackoverflow.com/questions/9149263/t4-output-to-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!