3

我正在尝试使用 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 方式)而不是 camelCasing 并且没有下划线生成文件?

由于字段名称不同,t4toolbox 生成的代码会导致 400+ 错误。

4

1 回答 1

1

您可以复制要在项目中修改的 T4 Linq2Sql 模板。您只需创建与 T4Toolbox 中相同的层次结构:在项目的根目录中,添加一个文件夹T4Toolbox/LinqToSql并将模板LinqToSqlEntityClassTemplate.tt从 T4Toolbox 安装复制到您的项目中。您只需编辑FieldName方法即可更改字段的命名。

Visual Studio 中的项目视图

于 2011-02-18T11:27:35.077 回答