DynamicFilterInfo新增UseAllLogic,使用所有逻辑运算符的模式,默认为False。#1927
Open
fuyuesong wants to merge 1 commit intodotnetcore:masterfrom
Open
DynamicFilterInfo新增UseAllLogic,使用所有逻辑运算符的模式,默认为False。#1927fuyuesong wants to merge 1 commit intodotnetcore:masterfrom
fuyuesong wants to merge 1 commit intodotnetcore:masterfrom
Conversation
False:按照原来的模式,只有分组的逻辑运算符会生成到查询条件中,只有OR分组会生成括号。 True:按照新的模式,所有的逻辑运算符都会生成到查询条件中,所有分组(AND或OR)都会生成括号。 WhereDynamicFilter(DynamicFilterInfo filter)中保留原有模式,并增加了对新模式的处理。
Collaborator
if (useAllLogic)
{
sb = sb.Replace("( AND", "(")
.Replace("( OR", "(");
}这种暴力替换的方式,可能导致 bug 实现方式和我的预期可能不太一样,建议在外层做一次转换,把 DynamicFilterInfo 转换成相应的 DynamicFilterInfo,就不需要修改内部实现了。测试成本高。 |
Author
这样实现是比较简单的方式,也可以在添加逻辑运算符前先判断SQL末尾是否是括号,或者其它的方式。理论上,只有和括号和逻辑运算符连在一起的才会被处理,不会出现其它情况。或者你可以举个例子,什么情况下可能出现错误。 我有考虑过在外层做转换,但是没有找到好的简单的方式去实现,因为按照SQL的查询逻辑可能有各种组合,千变万化各种情况。如果考虑不够全面,可能会有很多不易发现的问题。 目前的实现方式是保留原有模式不影响的前提下,按照查询设计器的分组及条件的层次结构完整转译为查询语句的方法。我已经有进行多层次不同逻辑运算符测试。理论上,这只是把树形结构转为树形结构的查询条件语句,中间不做任何逻辑的变动处理,应该不需要大量测试,只要确保结构能原样转换即可。 或者看看Freesql能否提供一种对WhereDynamicFilter的简单扩展,例如我可以添加一个扩展方法WhereDynamicFilterNew来实现这个需求。如果直接改源码,后续无法直接跟着官方项目更新。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
False:按照原来的模式,只有分组的逻辑运算符会生成到查询条件中,只有OR分组会生成括号。
True:按照新的模式,所有的逻辑运算符都会生成到查询条件中,所有分组(AND或OR)都会生成括号。
WhereDynamicFilter(DynamicFilterInfo filter)中保留原有模式,并增加了对新模式的处理。