在某些匹配中使用其他匹配
这并不是真正的困难,但当我学习语言时,我希望我的代码有点优雅,但我不喜欢这样:
match aver with
| 1 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date]),
DATEPART(HOUR, DT.[Date]),
(DATEPART(MINUTE, DT.[Date]) / 10)"
| 2 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date]),
DATEPART(HOUR, DT.[Date])"
| 3 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date])"
| 4 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date])"
| _ -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date]),
DATEPART(HOUR, DT.[Date]),
DATEPART(MINUTE, DT.[Date])"
因为我真的希望它像这样:
match aver with
| 4 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date])"
| 3 -> 2 + @",DATEPART(DAY, DT.[Date])"
| 2 -> 3 + @",DATEPART(HOUR, DT.[Date])"
| 1 -> 3 + @", (DATEPART(MINUTE, DT.[Date]) / 10)"
| _ -> 3 + @", DATEPART(MINUTE, DT.[Date])"
是否有某种方法可以在某些匹配中使用其他匹配?
It's not really hard trouble but as I'm learning language I want my code being sorta elegant and I don't like this :
match aver with
| 1 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date]),
DATEPART(HOUR, DT.[Date]),
(DATEPART(MINUTE, DT.[Date]) / 10)"
| 2 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date]),
DATEPART(HOUR, DT.[Date])"
| 3 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date])"
| 4 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date])"
| _ -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date]),
DATEPART(DAY, DT.[Date]),
DATEPART(HOUR, DT.[Date]),
DATEPART(MINUTE, DT.[Date])"
because I really want it alike this :
match aver with
| 4 -> @" GROUP BY
DATEPART(YEAR, DT.[Date]),
DATEPART(MONTH, DT.[Date])"
| 3 -> 2 + @",DATEPART(DAY, DT.[Date])"
| 2 -> 3 + @",DATEPART(HOUR, DT.[Date])"
| 1 -> 3 + @", (DATEPART(MINUTE, DT.[Date]) / 10)"
| _ -> 3 + @", DATEPART(MINUTE, DT.[Date])"
is there some way to use another matchings in some matching ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是最有效的,但它应该展示您正在寻找的内容。
Not the most efficient, but it should demonstrate what you're looking for.