gpt4 book ai didi

C#高级查询语句字符串处理

转载 作者:行者123 更新时间:2023-11-30 22:49:39 24 4
gpt4 key购买 nike

我正在寻找将字符串处理成对象树的最佳实践或库..

例子如下:

[age] = '37' And [gender] Is Not Null And [optindate] > '2003/01/01' And [idnumber] Is Null And ([saresident] = '52' Or [citizenship] Like 'abc%')"

我应该能够将其对象化为这样的树:

{attribute='age', operator='=', value='37', opperand='And'}
{attribute='gender', operator='Is Not Null', value='', opperand='And'}
{attribute='optindate', operator='>', value='2003/01/01', opperand='And'}

等....

任何建议都会很棒!

最佳答案

如果需要将操作存储在树结构中,则应使用后缀或前缀表示法。例如年龄 = 37 且性别不为空应存储为

and = 37 岁 != gender null

所以这棵树应该是这样的

        and
= !=
age 37 gender null

您可以使用这些链接了解更多详细信息:Notation Used for OperationsExpressions, Conversion and Evaluation with C (All you need to know about Expressions)

关于C#高级查询语句字符串处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1012242/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com