C# - SQL WITH 子句
只是寻找想法 -
我有一个需要用 C# 解析的 SQL 语句。它的格式基本上如下 -
WITH TableX as (
-- something else could be here..
select field1, field2, .. fieldX
from mytable
-- something else could be here..
)
-- something else could be here..
select /*THESE FIELDS ARE BEING REPLACED*/ TableX.field1, TableX.field2, .. TableX.fieldX
from TableX
-- something else could be here.. ie, more joins, selecting from subqueries. Basically another select could exist here.
关于如何用保证在结果集中的另一组字段替换“TableX.field1,TableX.field2,.. TableX.fieldX”有什么想法吗?
Just fishing for ideas-
I have a SQL statement that I need to parse in C#. It is formatted basically as follows -
WITH TableX as (
-- something else could be here..
select field1, field2, .. fieldX
from mytable
-- something else could be here..
)
-- something else could be here..
select /*THESE FIELDS ARE BEING REPLACED*/ TableX.field1, TableX.field2, .. TableX.fieldX
from TableX
-- something else could be here.. ie, more joins, selecting from subqueries. Basically another select could exist here.
Any ideas on how to replace "TableX.field1, TableX.field2, .. TableX.fieldX" with another group of field guaranteed to be in the result set?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用完整的 sql 解析器来构建解析树,然后从那里有选择地替换项目。
这是一项不平凡的任务。
you could use a complete sql parser to build a parse tree, then replace the items selectively from there.
non-trivial task.