简体   繁体   English

Fluent NHibernate 列名约定

[英]Fluent NHibernate column name conventions

I want to create a convention for column names using Fluent NHibernate auto mapping.我想使用 Fluent NHibernate 自动映射为列名创建约定。 There is a blog entry that states that property conventions can be set like this:有一篇博客文章指出可以像这样设置属性约定:

ConventionBuilder.Property.When(
  x => x.Property.PropertyType == typeof(int),
  x => x.ColumnName(x.Property.Name + "Num")
)

But the problem is, that x only has a ColumnNames property and has no ColumnName method .但问题是, x只有一个ColumnNames属性而没有ColumnName方法 How can I change the property mapping conventions using the new style configuration?如何使用新样式配置更改属性映射约定?

(PS: I'm using the latest binary avaialable on the site as of today) (PS:截至今天,我使用的是网站上可用的最新二进制文件)

Okay... it seems they changed from the ColumnName property to a ColumnNames list.好的...他们似乎从 ColumnName 属性更改为 ColumnNames 列表。 You have to add your columnname to this list like this:您必须像这样将您的列名添加到此列表中:

ConventionBuilder.Property.Always(s => s.ColumnNames.Add(s.Property.Name + "Num"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM