mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 修复 Enum.ToString() 即使 MapType=int 也应解析成 string;#1252 #806
This commit is contained in:
parent
b164a08747
commit
2a3db8a2c2
@ -590,7 +590,7 @@ namespace base_entity
|
|||||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.OdbcDameng, "Driver={DM8 ODBC DRIVER};Server=127.0.0.1:5236;Persist Security Info=False;Trusted_Connection=Yes;UID=USER1;PWD=123456789")
|
//.UseConnectionString(FreeSql.DataType.OdbcDameng, "Driver={DM8 ODBC DRIVER};Server=127.0.0.1:5236;Persist Security Info=False;Trusted_Connection=Yes;UID=USER1;PWD=123456789")
|
||||||
//.UseConnectionString(DataType.QuestDb, "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
.UseConnectionString(DataType.QuestDb, "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
||||||
.UseMonitorCommand(cmd =>
|
.UseMonitorCommand(cmd =>
|
||||||
{
|
{
|
||||||
Console.WriteLine(cmd.CommandText + "\r\n");
|
Console.WriteLine(cmd.CommandText + "\r\n");
|
||||||
@ -602,6 +602,16 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
var qr1 = fsql.SelectLongSequence(10, () => new
|
||||||
|
{
|
||||||
|
rndstr = QuestFunc.rnd_str(10, 5, 10, 0),
|
||||||
|
rnddate = QuestFunc.rnd_date(QuestFunc.to_date("2020", "yyyy"), QuestFunc.to_date("2023", "yyyy")),
|
||||||
|
test1 = TaskStatus.Canceled.ToString()
|
||||||
|
})
|
||||||
|
.From<User1>()
|
||||||
|
.InnerJoin((a, b) => a.rndstr == b.Username).ToList();
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
fsql.Aop.ParseExpression += (_, e) =>
|
fsql.Aop.ParseExpression += (_, e) =>
|
||||||
{
|
{
|
||||||
@ -669,14 +679,6 @@ namespace base_entity
|
|||||||
.Where(a => geo.GetGeometryN(0).Distance(a.Center) < 100).ToSql();
|
.Where(a => geo.GetGeometryN(0).Distance(a.Center) < 100).ToSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
var qr1 = fsql.SelectLongSequence(10, () => new
|
|
||||||
{
|
|
||||||
rndstr = QuestFunc.rnd_str(10, 5, 10, 0),
|
|
||||||
rnddate = QuestFunc.rnd_date(QuestFunc.to_date("2020", "yyyy"), QuestFunc.to_date("2023", "yyyy"))
|
|
||||||
})
|
|
||||||
.From<User1>()
|
|
||||||
.InnerJoin((a, b) => a.rndstr == b.Username).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
var now_to_timezone = "";
|
var now_to_timezone = "";
|
||||||
var timeOffset = (int)TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
|
var timeOffset = (int)TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
|
||||||
|
@ -733,15 +733,6 @@
|
|||||||
<param name="modelBuilder"></param>
|
<param name="modelBuilder"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSqlDbContextExtensions.ApplyConfigurationsFromAssembly(FreeSql.ICodeFirst,System.Reflection.Assembly,System.Func{System.Type,System.Boolean})">
|
|
||||||
<summary>
|
|
||||||
根据Assembly扫描所有继承IEntityTypeConfiguration<T>的配置类
|
|
||||||
</summary>
|
|
||||||
<param name="codeFirst"></param>
|
|
||||||
<param name="assembly"></param>
|
|
||||||
<param name="predicate"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
|
<member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
|
||||||
<summary>
|
<summary>
|
||||||
创建普通数据上下文档对象
|
创建普通数据上下文档对象
|
||||||
@ -800,14 +791,5 @@
|
|||||||
<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>
|
||||||
|
@ -88,7 +88,18 @@ namespace FreeSql.ClickHouse
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as String)" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as String)" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Custom
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return _utils.Adapter.LambdaRandom_NextDouble;
|
if (callExp.Method.DeclaringType.IsNumberType()) return _utils.Adapter.LambdaRandom_NextDouble;
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,18 @@ namespace FreeSql.Custom.MySql
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Custom.Oracle
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,18 @@ namespace FreeSql.Custom.PostgreSQL
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +93,21 @@ namespace FreeSql.Custom.SqlServer
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
var gentype2 = callExp.Object.Type.NullableTypeOrThis();
|
if (callExp.Object != null)
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
|
{
|
||||||
|
var gentype2 = callExp.Object.Type.NullableTypeOrThis();
|
||||||
|
if (gentype2.IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Dameng
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,18 @@ namespace FreeSql.Firebird
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as blob sub_type 1)" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as blob sub_type 1)" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,18 @@ namespace FreeSql.GBase
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as varchar(8000))" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as varchar(8000))" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,18 @@ namespace FreeSql.KingbaseES
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,18 @@ namespace FreeSql.MsAccess
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rnd";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rnd";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? MsAccessUtils.GetCastSql(getExp(callExp.Object), typeof(string)) : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? MsAccessUtils.GetCastSql(getExp(callExp.Object), typeof(string)) : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,18 @@ namespace FreeSql.MySql
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Odbc.Default
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return _utils.Adapter.LambdaRandom_NextDouble;
|
if (callExp.Method.DeclaringType.IsNumberType()) return _utils.Adapter.LambdaRandom_NextDouble;
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? _utils.Adapter.LambdaConvert_ToString(callExp.Object.Type, getExp(callExp.Object)) : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,18 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,18 @@ namespace FreeSql.Odbc.MySql
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as char)" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,18 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +93,21 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
var gentype2 = callExp.Object.Type.NullableTypeOrThis();
|
if (callExp.Object != null)
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
|
{
|
||||||
|
var gentype2 = callExp.Object.Type.NullableTypeOrThis();
|
||||||
|
if (gentype2.IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Oracle
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "dbms_random.value";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"to_char({getExp(callExp.Object)})" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.PostgreSQL
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,17 @@ namespace FreeSql.QuestDb
|
|||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null)
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,18 @@ namespace FreeSql.ShenTong
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,10 +92,21 @@ namespace FreeSql.SqlServer
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "rand()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
var gentype2 = callExp.Object.Type.NullableTypeOrThis();
|
if (callExp.Object != null)
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
|
{
|
||||||
$"cast({getExp(callExp.Object)} as varchar(36))" :
|
var gentype2 = callExp.Object.Type.NullableTypeOrThis();
|
||||||
|
if (gentype2.IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? (gentype2 == typeof(Guid) ?
|
||||||
|
$"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;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,18 @@ namespace FreeSql.Sqlite
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as character)" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as character)" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,18 @@ namespace FreeSql.Xugu
|
|||||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||||
return null;
|
return null;
|
||||||
case "ToString":
|
case "ToString":
|
||||||
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
if (callExp.Object != null)
|
||||||
|
{
|
||||||
|
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||||
|
{
|
||||||
|
tsc.SetMapColumnTmp(null);
|
||||||
|
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||||
|
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||||
|
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||||
|
return enumStr;
|
||||||
|
}
|
||||||
|
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user