diff --git a/Providers/FreeSql.Provider.Custom/Oracle/CustomOracleCodeFirst.cs b/Providers/FreeSql.Provider.Custom/Oracle/CustomOracleCodeFirst.cs index 8478cc886..750326390 100644 --- a/Providers/FreeSql.Provider.Custom/Oracle/CustomOracleCodeFirst.cs +++ b/Providers/FreeSql.Provider.Custom/Oracle/CustomOracleCodeFirst.cs @@ -353,8 +353,9 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column); if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) { - var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); - insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; + var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim(); + if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB") + insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; } if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})"; diff --git a/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs b/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs index 3d63ef392..98e237c8e 100644 --- a/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs +++ b/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs @@ -359,18 +359,11 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) { var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); - var charMatch = Regex.Match(dbtypeNoneNotNull, "(N?)VARCHAR(2?)\\((?[0-9]+)\\)"); - - if(charMatch != null) - { - if (ushort.TryParse(charMatch.Groups["precision"]?.Value, out var precision)) - { - dbtypeNoneNotNull = Regex.Replace(dbtypeNoneNotNull, $"\\(({precision})\\)", $""); - } - } - - insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; + if (charMatch != null && ushort.TryParse(charMatch.Groups["precision"]?.Value, out var precision)) + dbtypeNoneNotNull = Regex.Replace(dbtypeNoneNotNull, $"\\(({precision})\\)", $""); + if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB") + insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; } if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})"; diff --git a/Providers/FreeSql.Provider.Odbc/Oracle/OdbcOracleCodeFirst.cs b/Providers/FreeSql.Provider.Odbc/Oracle/OdbcOracleCodeFirst.cs index 2b83b13f4..dd7126c3e 100644 --- a/Providers/FreeSql.Provider.Odbc/Oracle/OdbcOracleCodeFirst.cs +++ b/Providers/FreeSql.Provider.Odbc/Oracle/OdbcOracleCodeFirst.cs @@ -355,8 +355,9 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column); if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) { - var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); - insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; + var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim(); + if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB") + insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; } if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})"; diff --git a/Providers/FreeSql.Provider.Oracle/OracleCodeFirst.cs b/Providers/FreeSql.Provider.Oracle/OracleCodeFirst.cs index 171d54535..e3bfb31f9 100644 --- a/Providers/FreeSql.Provider.Oracle/OracleCodeFirst.cs +++ b/Providers/FreeSql.Provider.Oracle/OracleCodeFirst.cs @@ -390,8 +390,9 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column); if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) { - var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); - insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; + var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim(); + if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB") + insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; } if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})";