WCF REST:不区分大小写的查询字符串参数,建议的命名约定 - 使用下划线还是?

发布于 2024-09-26 03:37:42 字数 697 浏览 7 评论 0原文

看来您可以传递给 WCF REST 中的其余方法的查询字符串参数不区分大小写 - 实际上这是有道理的。

对于包含 2 个单词的参数,使用 _(下划线),最好的命名约定是什么?我从来不喜欢这个,我更喜欢使用驼峰命名法,但如果它不敏感,我还有什么其他选择?

例如,这是我方法的 WebGet

  [WebGet(UriTemplate = "?skip={skip}&top={top}&unansweredOnly={unansweredOnly}")]

注意,我有单词 unansweredOnly,所以我可以这样做 unanswered_only.... 或者当然我可以像 unansweredOnly (驼峰式)一样保留它,但当然 unansweredonly 也可以...但我可以在服务文档中将其显示为 UnansweredOnly。

现在令人惊讶的是,在 wcf 休息服务的帮助页面中,它显示为驼峰式:-)

  (from help page)  ?skip={skip}&top={top}&unansweredOnly={unansweredOnly}

我想我正在尝试了解每个人都在做什么,以及推荐的做事方式是什么。

我真的很感激一些反馈。

我不想养成坏习惯,

提前致谢

It appears the query string parameters you can pass to a rest method in WCF REST is case insesitive - actually this makes sense.

What the best naming convention for parameters with 2 words, using an _ (underscore) ?? I never liked this, i prefered to use camelCasing but if its insensitive what other options to do i have?

for example here is my method's WebGet

  [WebGet(UriTemplate = "?skip={skip}&top={top}&unansweredOnly={unansweredOnly}")]

Notice i have the word unansweredOnly, so i could do this unanswered_only.... or of course i could leave it like unansweredOnly (camelcasing) but of course unansweredonly would also work... but i could show it as UnansweredOnly in the documentation for the service.

Now something surprising is that in the help page of wcf rest service it shows it as camelcasing :-)

  (from help page)  ?skip={skip}&top={top}&unansweredOnly={unansweredOnly}

I suppose i am trying to get an idea what everyone is doing, aand whats the recommended way of doing things.

I would really apprecaite some feedback.

I don't want to get into a bad habit

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

终止放荡 2024-10-03 03:37:42

http 规范规定查询字符串应区分大小写。

如果 WCF 不区分大小写,为什么会阻止您使用驼峰式大小写?

即使您的 Web 框架使用区分大小写的查询字符串,您也不应该使用仅大小写不同的查询字符串参数。

The http spec says that the query string should be case sensitive.

If WCF is case-insensitive, why would that stop you from using camel casing?

Even if your web framework use case sensitive query strings, you should never use query string parameters that differ only in case.

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