为什么 visual studio 将 CommandText 放在 resx 资源文件中而不是设计器代码隐藏文件?
Why does visual studio put CommandText in resx resource file vs designer code behind file?
有时我存储在 OdbcCommand.CommandText
中的查询会保存到后面的 designer.cx 代码中,有时会保存在 .resx 资源文件中。是什么原因导致它转到代码后面 vs 资源文件?
有没有办法强制 visual studio 将我的查询保存在资源文件中(反之亦然),这样我就不必在两个地方都查看。
最后,经过一番谷歌搜索,我找到了发布的答案 here:
I have examined it a little further. It appears that the commandtext is
saved in the resource when it's length is more the 200 characters. This not
only applies to the commandtext property, but to all string properties, e.g.
the Label.Text. It's saved to the resouce even if the localizable property of
the form, usercontrol or component is false. When you decrease the length of
the string, the property is removed from the resource file and placed in the
Designer.cs file.
So it seems you have no control over the fact if a lengthy string is saved
in the resource or not. In the case of the commandtext that's very
dangerouse, because a translator of the resource could change the commandtext
to a wrong statement.
显然没有办法改变这种行为。我确实确认有 200 个字符的限制,不包括白色 space.
有时我存储在 OdbcCommand.CommandText
中的查询会保存到后面的 designer.cx 代码中,有时会保存在 .resx 资源文件中。是什么原因导致它转到代码后面 vs 资源文件?
有没有办法强制 visual studio 将我的查询保存在资源文件中(反之亦然),这样我就不必在两个地方都查看。
最后,经过一番谷歌搜索,我找到了发布的答案 here:
I have examined it a little further. It appears that the commandtext is saved in the resource when it's length is more the 200 characters. This not only applies to the commandtext property, but to all string properties, e.g. the Label.Text. It's saved to the resouce even if the localizable property of the form, usercontrol or component is false. When you decrease the length of the string, the property is removed from the resource file and placed in the Designer.cs file. So it seems you have no control over the fact if a lengthy string is saved in the resource or not. In the case of the commandtext that's very dangerouse, because a translator of the resource could change the commandtext to a wrong statement.
显然没有办法改变这种行为。我确实确认有 200 个字符的限制,不包括白色 space.