@@ -95,7 +95,7 @@ internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectT
9595 argIndex ++ ;
9696 }
9797 if ( objType == null ) objType = callExp . Method . DeclaringType ;
98- if ( objType != null ) {
98+ if ( objType != null || objType . IsArray || typeof ( IList ) . IsAssignableFrom ( callExp . Method . DeclaringType ) ) {
9999 var left = objExp == null ? null : getExp ( objExp ) ;
100100 switch ( objType . FullName ) {
101101 case "Newtonsoft.Json.Linq.JToken" :
@@ -134,32 +134,30 @@ internal override string ExpressionLambdaToSqlOther(Expression exp, List<SelectT
134134 case "Values" : return $ "avals({ left } )";
135135 }
136136 }
137- if ( objType . IsArray || typeof ( IList ) . IsAssignableFrom ( callExp . Method . DeclaringType ) ) {
138- switch ( callExp . Method . Name ) {
139- case "Any" :
140- if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) ) left = $ "array[{ left . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
141- return $ "(case when { left } is null then 0 else array_length({ left } ,1) end > 0)";
142- case "Contains" :
143- //判断 in 或 array @> array
144- var right1 = getExp ( callExp . Arguments [ argIndex ] ) ;
145- if ( left . StartsWith ( "array[" ) || left . EndsWith ( "]" ) )
146- return $ "{ right1 } in ({ left . Substring ( 6 , left . Length - 7 ) } )";
147- if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) )
148- return $ "{ right1 } in { left } ";
149- if ( right1 . StartsWith ( "(" ) || right1 . EndsWith ( ")" ) ) right1 = $ "array[{ right1 . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
150- return $ "({ left } @> array[{ right1 } ])";
151- case "Concat" :
152- if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) ) left = $ "array[{ left . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
153- var right2 = getExp ( callExp . Arguments [ argIndex ] ) ;
154- if ( right2 . StartsWith ( "(" ) || right2 . EndsWith ( ")" ) ) right2 = $ "array[{ right2 . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
155- return $ "({ left } || { right2 } )";
156- case "GetLength" :
157- case "GetLongLength" :
158- case "Length" :
159- case "Count" :
160- if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) ) left = $ "array[{ left . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
161- return $ "case when { left } is null then 0 else array_length({ left } ,1) end";
162- }
137+ switch ( callExp . Method . Name ) {
138+ case "Any" :
139+ if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) ) left = $ "array[{ left . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
140+ return $ "(case when { left } is null then 0 else array_length({ left } ,1) end > 0)";
141+ case "Contains" :
142+ //判断 in 或 array @> array
143+ var right1 = getExp ( callExp . Arguments [ argIndex ] ) ;
144+ if ( left . StartsWith ( "array[" ) || left . EndsWith ( "]" ) )
145+ return $ "{ right1 } in ({ left . Substring ( 6 , left . Length - 7 ) } )";
146+ if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) )
147+ return $ "{ right1 } in { left } ";
148+ if ( right1 . StartsWith ( "(" ) || right1 . EndsWith ( ")" ) ) right1 = $ "array[{ right1 . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
149+ return $ "({ left } @> array[{ right1 } ])";
150+ case "Concat" :
151+ if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) ) left = $ "array[{ left . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
152+ var right2 = getExp ( callExp . Arguments [ argIndex ] ) ;
153+ if ( right2 . StartsWith ( "(" ) || right2 . EndsWith ( ")" ) ) right2 = $ "array[{ right2 . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
154+ return $ "({ left } || { right2 } )";
155+ case "GetLength" :
156+ case "GetLongLength" :
157+ case "Length" :
158+ case "Count" :
159+ if ( left . StartsWith ( "(" ) || left . EndsWith ( ")" ) ) left = $ "array[{ left . TrimStart ( '(' ) . TrimEnd ( ')' ) } ]";
160+ return $ "case when { left } is null then 0 else array_length({ left } ,1) end";
163161 }
164162 }
165163 break ;
0 commit comments