在类上设置访问器似乎不适用于 TextInfo 和 TitleCase
在使用 nhibernate 映射时,我注意到我拥有的属性设置器正在超载(或被忽略)。这是 nhibernate 映射的预期默认行为。
所以我将其更改为使用 field.camelCase - 这样 NHibernate 将设置实体类的私有字段而不是属性 getter/setter,这样我就可以使用 getter 来实现
get { return (new TextInfo()).ToTitleCase( _property);}
我注意到输出仍然是持久的,并且此方法不起作用。
我将其更改为 _property.ToLower();并且输出预计为小写文本。
看来我在 TextInfo 方面做得不太好。 NHibernate 工作正常(NB NHibernate 很摇滚)
有什么想法为什么 TextInfo 会这样做吗?可能是我错过了一些微不足道的事情..
Whilst playing around with an nhibernate mapping, I noticed that a property setter I had was being overloaded (or ignored). This is expected default behaviour with an nhibernate mapping.
So I changed it to use the field.camelCase - so NHibernate would set the private field of the entity class and not the propety getter/setter so I could then use the getter to implement
get { return (new TextInfo()).ToTitleCase(_property);}
I noticed that the output was still what was persisted and this method did not work.
I changed the to _property.ToLower(); and the output was expected as lower case text.
So it appears that there is something I have not done quite right with TextInfo. NHibernate was working correctly (NB NHibernate rocks)
Any ideas why TextInfo is doing this? Probably something trivial I have missed..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,它不适用于大写字符串,uhmmmm Microsoft ;P
您的解决方案是首先将输入小写:
For some reason it doesn't work with upper-case strings, uhmmmm Microsoft ;P
Your solution will be to lower case the input first: