Fluent Nhibernate - 集合名称命名约定
即使我使用或不使用访问策略,是否可以为实体的所有集合设置命名约定,以便所有集合名称都是 {EnityName}s
而不是 {entityName}s
(因为 Access.CamelCaseField(Prefix.Underscore) 第一个字母较低)?
或者有没有一种方法可以告诉NHibernate它应该在SetFetchMode
方法中使用不区分大小写的associationPath?
此方法不区分大小写:
ICriteria SetFetchMode(string associationPath, FetchMode mode)
我尝试构建一种类型安全的方式来设置associationPath
编辑:
associationPath是集合的名称属性。
<set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true">
我想为 name 属性定义命名约定。
编辑:
我发现了这样的东西:
public class LowercaseCollectionNameConvention : IClassConvention
{
public void Apply(IClassInstance instance)
{
instance.Collections. ...
}
}
有人知道如何使用这个吗?
Is it possible to set a naming convention for all collection of an entity even if I use the Access Strategy or not, so that all collection names are {EnityName}s
instead of {entityName}s
(because of Access.CamelCaseField(Prefix.Underscore) the first letter is lower)?
Or is there a way where I can tell NHibernate that it shall use the associationPath case insensitive in the SetFetchMode
method?
This method is not case insensitive:
ICriteria SetFetchMode(string associationPath, FetchMode mode)
I try to build a type safe way of setting the associationPath
EDIT:
The associationPath is the name attribute of the collection.
<set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true">
I want to define a naming convention for the name attribute.
EDIT:
I found something like this:
public class LowercaseCollectionNameConvention : IClassConvention
{
public void Apply(IClassInstance instance)
{
instance.Collections. ...
}
}
Does someone one know how to use this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否完全理解你问题的背景。如果您在映射和模式生成期间追求关系的命名策略,那么您需要执行某种“约定”。
我最近在博客上写了我的约定 http://blog .zoolutions.se/post/2010/07/03/Inflector-e28093-renaming-utilities.aspx 和 http://blog.zoolutions.se/post/2010/07/05/All-my-current-Fluent-NHibernate-Conventions .aspx
如果您可以添加一些更好的描述,我将很乐意扩展我的答案。
编辑 如果您从我的博客或任何其他可以找到的位置复制 Inflektor 类,那么以下内容应该会让您非常接近:
I am not sure I fully understand the context of your question. If you are after a naming strategy for the relationship during mapping and schema generation then you need to do some sort of "Convention".
I recently blogged my conventions http://blog.zoolutions.se/post/2010/07/03/Inflector-e28093-renaming-utilities.aspx and http://blog.zoolutions.se/post/2010/07/05/All-my-current-Fluent-NHibernate-Conventions.aspx
If you could add some better description I'll be happy to extend my answer.
EDIT The following should get you pretty close if you copy the Inflektor class from my blog or any other location it can be found: