SubSonic 3.0.0.3 C# 我们应该如何处理保留字?
我有一个旧数据库,其列名称如“void”。 我还有几个 Microsoft SSIS 日志数据库。 它们的列名称如“事件”和“操作员”。 看起来我们需要尽早在 Settings.ttinclude 模板中设置列上的 CleanName,但我不太确定解决此问题的最佳方法,因为保留字列表可能会很长。 这应该是一个单独的包含吗? 我很乐意做出贡献,但我首先需要你们这些聪明人提供一些设计意见。
I have a legacy database that has column names like "void". I also have several Microsoft SSIS log databases. those have column names like "event" and "operator". It looks like we need to set the CleanName on the column early on in Settings.ttinclude template, but I am not quite sure the best way to tackle this since the list of reserved words might get long. Should this be a separate include? I'd be happy to contribute, but I'd like some design input from you smart people first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C# 中的保留字可以通过在代码中添加“@”符号来处理。 例如,
由于编译器错误而失败,但
还好。 这也适用于属性名称。 您可以升级 T4 模板来检查保留字列表,如果存在匹配项,则在名称前面添加“@”符号。
至于将其添加到 Subsonic 中的最佳方法,我必须进行更多挖掘。
Reserved words in c# can be handled in code by prepending them with the '@' symbol. For example,
fails with a compiler error, but
is just fine. This works for property names as well. You could probably upgrade your T4 templates to check a list of reserved words, and if there is a match, prepend the '@' symbol in front of the name.
As to the best way of adding this into Subsonic, I'd have to do more digging.