T4 工具箱 Linq2Sql
我正在尝试使用 t4toolbox 为项目生成 linq2sql 类。已经有很多代码是针对默认 dbml 生成的代码编写的。
在 LinqToSqlEntityClassTemplate.tt 文件中,有没有
/// <para>
/// While MSLinqToSQLGenerator generates field names as property name with an
/// underscore prefix, this method simply converts the property name to camelCase.
/// This is done for consistency with the StyleCop rule SA1306: Variable names
/// must start with a lower-case letter.
/// </para>
办法让它以默认方式(Visual Studio 方式)生成文件,而不是驼峰命名且没有下划线?
由于字段名称差异,t4toolbox 生成的代码会导致 400 多个错误。
I'm trying to use t4toolbox to generate the linq2sql classes for a project. There is already a lot of code written against the default dbml generated code.
In the LinqToSqlEntityClassTemplate.tt file it has
/// <para>
/// While MSLinqToSQLGenerator generates field names as property name with an
/// underscore prefix, this method simply converts the property name to camelCase.
/// This is done for consistency with the StyleCop rule SA1306: Variable names
/// must start with a lower-case letter.
/// </para>
Is there any way to make it generate the files in the default manner (Visual Studio way) instead of camelCasing and not having underscores?
The code generated by t4toolbox causes 400+ errors because of the field name differences.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在项目中复制要修改的 T4 Linq2Sql 模板。您只需创建与 T4Toolbox 中相同的层次结构:在项目的根目录中,添加文件夹
T4Toolbox/LinqToSql
并从 T4Toolbox 安装中复制模板LinqToSqlEntityClassTemplate.tt
到你的项目中。您只需编辑FieldName
方法即可更改字段的命名。You can copy the T4 Linq2Sql template that you want to modify in you project. You just have to make the same hierarchy as in T4Toolbox: at the root of your project, add a folder
T4Toolbox/LinqToSql
and copy the templateLinqToSqlEntityClassTemplate.tt
from your T4Toolbox install into your project. You just have to edit theFieldName
methods to change the naming of fields.