在类上设置访问器似乎不适用于 TextInfo 和 TitleCase

发布于 2024-08-17 06:12:24 字数 437 浏览 5 评论 0原文

在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

茶底世界 2024-08-24 06:12:24

由于某种原因,它不适用于大写字符串,uhmmmm Microsoft ;P

您的解决方案是首先将输入小写:

get { return (new TextInfo()).ToTitleCase(_property.ToLower());}

For some reason it doesn't work with upper-case strings, uhmmmm Microsoft ;P

Your solution will be to lower case the input first:

get { return (new TextInfo()).ToTitleCase(_property.ToLower());}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文