帮助使用 FluentNHibernate 创建 ColumnName 约定
我一直在尝试为我的数据库表列指定自定义命名约定。到目前为止,我已经能够为表名称设置约定,但不能为实际列设置约定。我在互联网上看到了一些指南,但它们无法使用最新的 Fluent NHibernate (1.0.0 RTM)。
public class CamelCaseSplitNamingConvention : IClassConvention, IComponentConvention
{
public void Apply(IClassInstance instance)
{
instance.Table(instance.EntityType.Name.ChangeCamelCaseToUnderscore());
}
public void Apply(IComponentInstance instance)
{
// is this the correct call for columns? If not, which one?
}
}
请帮忙。
I've been trying to specify a custom naming convention for my database table columns. So far, I have been able to setup a convention for the table's name, but not the actual columns. I've seen a few guides on the internet, but they're not working using the latest Fluent NHibernate (1.0.0 RTM).
public class CamelCaseSplitNamingConvention : IClassConvention, IComponentConvention
{
public void Apply(IClassInstance instance)
{
instance.Table(instance.EntityType.Name.ChangeCamelCaseToUnderscore());
}
public void Apply(IComponentInstance instance)
{
// is this the correct call for columns? If not, which one?
}
}
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要创建列名称约定,您应该使用 IPropertyConvention 而不是 IComponentConvention。
例如(使用与示例代码中相同的方法将驼峰式大小写转换为下划线):
To create a convention for column names you should use an IPropertyConvention rather than an IComponentConvention.
For example (using the same method to convert camel case to underscore as in your example code):