- 优化 表达式解析变量或常量 ToString;

This commit is contained in:
2881099 2023-12-01 19:15:53 +08:00
parent c038097645
commit 5f01fbd457
28 changed files with 124 additions and 56 deletions

View File

@ -549,7 +549,6 @@ namespace base_entity
.UseNameConvert(NameConvertType.ToLower) .UseNameConvert(NameConvertType.ToLower)
//.UseMappingPriority(MappingPriorityType.Attribute, MappingPriorityType.FluentApi, MappingPriorityType.Aop) //.UseMappingPriority(MappingPriorityType.Attribute, MappingPriorityType.FluentApi, MappingPriorityType.Aop)
.UseAdoConnectionPool(true) .UseAdoConnectionPool(true)
.UseConnectionFactory(DataType.Xugu, () => null)
//.UseConnectionString(FreeSql.DataType.Sqlite, "data source=123.db") //.UseConnectionString(FreeSql.DataType.Sqlite, "data source=123.db")
//.UseConnectionString(DataType.Sqlite, "data source=db1.db;attachs=db2.db") //.UseConnectionString(DataType.Sqlite, "data source=db1.db;attachs=db2.db")
@ -560,7 +559,7 @@ namespace base_entity
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5") //.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
//.UseQuoteSqlName(false) //.UseQuoteSqlName(false)
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true") .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true") //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
//.UseAdoConnectionPool(false) //.UseAdoConnectionPool(false)
@ -599,13 +598,21 @@ namespace base_entity
.UseGenerateCommandParameterWithLambda(true) .UseGenerateCommandParameterWithLambda(true)
.Build(); .Build();
BaseEntity.Initialization(fsql, () => _asyncUow.Value); BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#endregion #endregion
var v1 = 123123123;
var mysql0111 = fsql.Select<User1>().Where(a => a.Nickname.Contains(v1.ToString())).ToSql();
var mysql0112 = fsql.Select<User1>().Where(a => a.Nickname.Contains(123123123.ToString())).ToSql();
var v2 = "123123123";
var mysql0113 = fsql.Select<User1>().Where(a => a.Nickname.Contains(v2)).ToSql();
var mysql0114 = fsql.Select<User1>().Where(a => a.Nickname.Contains(v2.ToString())).ToSql();
var mysql0115 = fsql.Select<User1>().Where(a => a.Nickname.Contains("123123123")).ToSql();
//fsql.Select<AsTableLog>().Where(a => a.createtime > DateTime.Now && a.createtime < DateTime.Now.AddMonths(1)).ToList(); //fsql.Select<AsTableLog>().Where(a => a.createtime > DateTime.Now && a.createtime < DateTime.Now.AddMonths(1)).ToList();
//var table = fsql.CodeFirst.GetTableByEntity(typeof(AsTableLog)); //var table = fsql.CodeFirst.GetTableByEntity(typeof(AsTableLog));
//table.SetAsTable(new ModAsTableImpl(fsql), table.ColumnsByCs[nameof(AsTableLog.click)]); //table.SetAsTable(new ModAsTableImpl(fsql), table.ColumnsByCs[nameof(AsTableLog.click)]);
fsql.CodeFirst.GetTableByEntity(typeof(AsTableLog)).AsTableImpl fsql.CodeFirst.GetTableByEntity(typeof(AsTableLog)).AsTableImpl
.SetTableName(0, "AsTableLog1") .SetTableName(0, "AsTableLog1")
.SetTableName(1, "AsTableLog2"); .SetTableName(1, "AsTableLog2");

View File

@ -800,5 +800,14 @@
<param name="that"></param> <param name="that"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
<summary>
批量注入 Repository可以参考代码自行调整
</summary>
<param name="services"></param>
<param name="globalDataFilter"></param>
<param name="assemblies"></param>
<returns></returns>
</member>
</members> </members>
</doc> </doc>

View File

@ -99,6 +99,8 @@ namespace FreeSql.ClickHouse
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as String)" : null; return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as String)" : null;
} }
return null; return null;

View File

@ -99,8 +99,10 @@ namespace FreeSql.Custom
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null;
} }
return null; return null;
} }

View File

@ -95,8 +95,10 @@ namespace FreeSql.Custom.MySql
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
} }
return null; return null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.Custom.Oracle
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
} }
return null; return null;
} }

View File

@ -98,8 +98,10 @@ namespace FreeSql.Custom.PostgreSQL
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
} }
return null; return null;
} }

View File

@ -103,8 +103,10 @@ namespace FreeSql.Custom.SqlServer
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ? var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
$"cast({getExp(callExp.Object)} as varchar(36))" : $"cast({getExp(callExp.Object)} as varchar(36))" :
$"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType() || gentype2.IsEnum ? "(100)" : "(max)")})") : null; $"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType() || gentype2.IsEnum ? "(100)" : "(max)")})") : null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.Dameng
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
} }
return null; return null;
} }

View File

@ -96,8 +96,10 @@ namespace FreeSql.Firebird
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as blob sub_type 1)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as blob sub_type 1)" : null;
} }
return null; return null;
} }

View File

@ -96,8 +96,10 @@ namespace FreeSql.GBase
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as varchar(8000))" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as varchar(8000))" : null;
} }
return null; return null;
} }

View File

@ -98,8 +98,10 @@ namespace FreeSql.KingbaseES
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
} }
return null; return null;
} }

View File

@ -69,8 +69,10 @@ namespace FreeSql.MsAccess
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? MsAccessUtils.GetCastSql(getExp(callExp.Object), typeof(string)) : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? MsAccessUtils.GetCastSql(getExp(callExp.Object), typeof(string)) : null;
} }
return null; return null;
} }

View File

@ -97,8 +97,10 @@ namespace FreeSql.MySql
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
} }
return null; return null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.Odbc.Dameng
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
} }
return null; return null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.Odbc.Default
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null;
} }
return null; return null;
} }

View File

@ -98,8 +98,10 @@ namespace FreeSql.Odbc.KingbaseES
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
} }
return null; return null;
} }

View File

@ -95,8 +95,10 @@ namespace FreeSql.Odbc.MySql
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
} }
return null; return null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.Odbc.Oracle
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
} }
return null; return null;
} }

View File

@ -98,8 +98,10 @@ namespace FreeSql.Odbc.PostgreSQL
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
} }
return null; return null;
} }

View File

@ -103,8 +103,10 @@ namespace FreeSql.Odbc.SqlServer
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ? var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
$"cast({getExp(callExp.Object)} as varchar(36))" : $"cast({getExp(callExp.Object)} as varchar(36))" :
$"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType() || gentype2.IsEnum ? "(100)" : "(max)")})") : null; $"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType() || gentype2.IsEnum ? "(100)" : "(max)")})") : null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.Oracle
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
} }
return null; return null;
} }

View File

@ -99,8 +99,10 @@ namespace FreeSql.PostgreSQL
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
} }
return null; return null;
} }

View File

@ -104,8 +104,10 @@ namespace FreeSql.QuestDb
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as string)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as string)" : null;
} }
return null; return null;
} }

View File

@ -98,8 +98,10 @@ namespace FreeSql.ShenTong
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
} }
return null; return null;
} }

View File

@ -102,8 +102,10 @@ namespace FreeSql.SqlServer
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ? var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
$"cast({getExp(callExp.Object)} as varchar(36))" : $"cast({getExp(callExp.Object)} as varchar(36))" :
$"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType() || gentype2.IsEnum ? "(100)" : "(max)")})") : null; $"cast({getExp(callExp.Object)} as nvarchar{(gentype2.IsNumberType() || gentype2.IsEnum ? "(100)" : "(max)")})") : null;
} }

View File

@ -95,8 +95,10 @@ namespace FreeSql.Sqlite
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as character)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as character)" : null;
} }
return null; return null;
} }

View File

@ -102,8 +102,10 @@ namespace FreeSql.Xugu
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc); var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType); tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr; return enumStr;
} }
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as text)" : null; var value = ExpressionGetValue(callExp.Object, out var success);
if (success) return formatSql(value, typeof(string), null, null);
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as text)" : null;
} }
return null; return null;
} }