You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
case"System.Int64":return$"cast({getExp(operandExp)} as bigint)";
37
37
case"System.SByte":return$"cast({getExp(operandExp)} as tinyint)";
38
38
case"System.Single":return$"cast({getExp(operandExp)} as decimal(14,7))";
39
-
case"System.String":returnoperandExp.Type.NullableTypeOrThis()==typeof(Guid)?$"cast({getExp(operandExp)} as varchar(36))":$"cast({getExp(operandExp)} as nvarchar)";
39
+
case"System.String":
40
+
returngentype==typeof(Guid)?
41
+
$"cast({getExp(operandExp)} as varchar(36))":
42
+
$"cast({getExp(operandExp)} as nvarchar{(gentype.IsNumberType()||gentype.IsEnum?"(100)":"(max)")})";
40
43
case"System.UInt16":return$"cast({getExp(operandExp)} as smallint)";
41
44
case"System.UInt32":return$"cast({getExp(operandExp)} as int)";
42
45
case"System.UInt64":return$"cast({getExp(operandExp)} as bigint)";
if(callExp.Object!=null)returncallExp.Arguments.Count==0?(callExp.Object.Type.NullableTypeOrThis()==typeof(Guid)?$"cast({getExp(callExp.Object)} as varchar(36))":$"cast({getExp(callExp.Object)} as nvarchar)"):null;
$"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType()||gentype2.IsEnum?"(100)":"(max)")})"):null;
90
96
returnnull;
91
97
}
92
98
@@ -262,10 +268,10 @@ public override string ExpressionLambdaToSqlCallString(MethodCallExpression exp,
262
268
case"Contains":
263
269
varargs0Value=getExp(exp.Arguments[0]);
264
270
if(args0Value=="NULL")return$"({left}) IS NULL";
265
-
if(exp.Method.Name=="StartsWith")return$"({left}) LIKE {(args0Value.EndsWith("'")?args0Value.Insert(args0Value.Length-1,"%"):$"(cast({args0Value} as nvarchar)+'%')")}";
266
-
if(exp.Method.Name=="EndsWith")return$"({left}) LIKE {(args0Value.StartsWith("'")?args0Value.Insert(1,"%"):$"('%'+cast({args0Value} as nvarchar))")}";
271
+
if(exp.Method.Name=="StartsWith")return$"({left}) LIKE {(args0Value.EndsWith("'")?args0Value.Insert(args0Value.Length-1,"%"):$"(cast({args0Value} as nvarchar(max))+'%')")}";
272
+
if(exp.Method.Name=="EndsWith")return$"({left}) LIKE {(args0Value.StartsWith("'")?args0Value.Insert(1,"%"):$"('%'+cast({args0Value} as nvarchar(max)))")}";
267
273
if(args0Value.StartsWith("'")&&args0Value.EndsWith("'"))return$"({left}) LIKE {args0Value.Insert(1,"%").Insert(args0Value.Length,"%")}";
268
-
return$"({left}) LIKE ('%'+cast({args0Value} as nvarchar)+'%')";
274
+
return$"({left}) LIKE ('%'+cast({args0Value} as nvarchar(max))+'%')";
269
275
case"ToLower":return$"lower({left})";
270
276
case"ToUpper":return$"upper({left})";
271
277
case"Substring":
@@ -336,7 +342,7 @@ public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression ex
@@ -454,7 +460,7 @@ public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression ex
454
460
case"Subtract":return$"({left}-({args1}))";
455
461
case"Equals":return$"({left} = {args1})";
456
462
case"CompareTo":return$"({left}-({args1}))";
457
-
case"ToString":return$"cast({left} as varchar)";
463
+
case"ToString":return$"cast({left} as varchar(100))";
458
464
}
459
465
}
460
466
returnnull;
@@ -477,7 +483,11 @@ public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp
477
483
case"ToInt64":return$"cast({getExp(exp.Arguments[0])} as bigint)";
478
484
case"ToSByte":return$"cast({getExp(exp.Arguments[0])} as tinyint)";
479
485
case"ToSingle":return$"cast({getExp(exp.Arguments[0])} as decimal(14,7))";
480
-
case"ToString":returnexp.Arguments[0].Type.NullableTypeOrThis()==typeof(Guid)?$"cast({getExp(exp.Arguments[0])} as varchar(36))":$"cast({getExp(exp.Arguments[0])} as nvarchar)";
case"System.Int64":return$"cast({getExp(operandExp)} as bigint)";
37
37
case"System.SByte":return$"cast({getExp(operandExp)} as tinyint)";
38
38
case"System.Single":return$"cast({getExp(operandExp)} as decimal(14,7))";
39
-
case"System.String":returnoperandExp.Type.NullableTypeOrThis()==typeof(Guid)?$"cast({getExp(operandExp)} as varchar(36))":$"cast({getExp(operandExp)} as nvarchar)";
39
+
case"System.String":returngentype==typeof(Guid)?
40
+
$"cast({getExp(operandExp)} as varchar(36))":
41
+
$"cast({getExp(operandExp)} as nvarchar{(gentype.IsNumberType()||gentype.IsEnum?"(100)":"(max)")})";
40
42
case"System.UInt16":return$"cast({getExp(operandExp)} as smallint)";
41
43
case"System.UInt32":return$"cast({getExp(operandExp)} as int)";
42
44
case"System.UInt64":return$"cast({getExp(operandExp)} as bigint)";
if(callExp.Object!=null)returncallExp.Arguments.Count==0?(callExp.Object.Type.NullableTypeOrThis()==typeof(Guid)?$"cast({getExp(callExp.Object)} as varchar(36))":$"cast({getExp(callExp.Object)} as nvarchar)"):null;
$"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType()||gentype2.IsEnum?"(100)":"(max)")})"):null;
90
95
returnnull;
91
96
}
92
97
@@ -262,10 +267,10 @@ public override string ExpressionLambdaToSqlCallString(MethodCallExpression exp,
262
267
case"Contains":
263
268
varargs0Value=getExp(exp.Arguments[0]);
264
269
if(args0Value=="NULL")return$"({left}) IS NULL";
265
-
if(exp.Method.Name=="StartsWith")return$"({left}) LIKE {(args0Value.EndsWith("'")?args0Value.Insert(args0Value.Length-1,"%"):$"(cast({args0Value} as nvarchar)+'%')")}";
266
-
if(exp.Method.Name=="EndsWith")return$"({left}) LIKE {(args0Value.StartsWith("'")?args0Value.Insert(1,"%"):$"('%'+cast({args0Value} as nvarchar))")}";
270
+
if(exp.Method.Name=="StartsWith")return$"({left}) LIKE {(args0Value.EndsWith("'")?args0Value.Insert(args0Value.Length-1,"%"):$"(cast({args0Value} as nvarchar(max))+'%')")}";
271
+
if(exp.Method.Name=="EndsWith")return$"({left}) LIKE {(args0Value.StartsWith("'")?args0Value.Insert(1,"%"):$"('%'+cast({args0Value} as nvarchar(max)))")}";
267
272
if(args0Value.StartsWith("'")&&args0Value.EndsWith("'"))return$"({left}) LIKE {args0Value.Insert(1,"%").Insert(args0Value.Length,"%")}";
268
-
return$"({left}) LIKE ('%'+cast({args0Value} as nvarchar)+'%')";
273
+
return$"({left}) LIKE ('%'+cast({args0Value} as nvarchar(max))+'%')";
269
274
case"ToLower":return$"lower({left})";
270
275
case"ToUpper":return$"upper({left})";
271
276
case"Substring":
@@ -336,7 +341,7 @@ public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression ex
@@ -452,7 +457,7 @@ public override string ExpressionLambdaToSqlCallTimeSpan(MethodCallExpression ex
452
457
case"Subtract":return$"({left}-({args1}))";
453
458
case"Equals":return$"({left} = {args1})";
454
459
case"CompareTo":return$"({left}-({args1}))";
455
-
case"ToString":return$"cast({left} as varchar)";
460
+
case"ToString":return$"cast({left} as varchar(100))";
456
461
}
457
462
}
458
463
returnnull;
@@ -475,7 +480,11 @@ public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp
475
480
case"ToInt64":return$"cast({getExp(exp.Arguments[0])} as bigint)";
476
481
case"ToSByte":return$"cast({getExp(exp.Arguments[0])} as tinyint)";
477
482
case"ToSingle":return$"cast({getExp(exp.Arguments[0])} as decimal(14,7))";
478
-
case"ToString":returnexp.Arguments[0].Type.NullableTypeOrThis()==typeof(Guid)?$"cast({getExp(exp.Arguments[0])} as varchar(36))":$"cast({getExp(exp.Arguments[0])} as nvarchar)";
0 commit comments