T4 输出到字符串

发布于 2025-01-02 19:20:20 字数 246 浏览 3 评论 0原文

我是 T4 的新手,我想生成 CRUD 存储过程、数据访问层、输出到字符串,我正在尝试创建一种对其他程序员也有用的 Web 服务 api,只需输入数据,然后下载 zip 文件。

我已经搜索了很多,但找不到一种生成字符串输出的方法,是否可能,任何文章、链接、一些代码(如果可能)都会有所帮助。

是的,我们也可以使用 StringBuilder,但是问题是“T4 输出到字符串”欢迎所有类型的答案,但请尽量关注问题。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

碍人泪离人颜 2025-01-09 19:20:20

您可以使用预处理的 T4 模板返回字符串而不是生成一个文件。

如果您将 Visual Studio 中文件的自定义工具属性更改为TextTemplateFilePreprocessor,那么当您保存 T4 模板时,将生成一个类。此类将有一个 TransformText 方法,该方法返回生成的文本。

MSDN 还提供了有关使用预处理的 T4 模板生成运行时文本的信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文