我正在尝试使用 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+ 错误。
最佳答案
您可以在项目中复制要修改的 T4 Linq2Sql 模板。您只需创建与 T4Toolbox 中相同的层次结构:在项目的根目录中,添加一个文件夹 T4Toolbox/LinqToSql
并从您的 T4Toolbox 安装中复制模板 LinqToSqlEntityClassTemplate.tt
进入你的项目。您只需编辑 FieldName
方法即可更改字段的命名。
关于c# - T4 工具箱 Linq2Sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5031028/