From e882269122b3b8f0df008016c1c2ef20960664b0 Mon Sep 17 00:00:00 2001 From: xieyidong Date: Wed, 13 Nov 2024 16:54:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=BE=BE=E6=A2=A6=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E6=97=B6=E7=94=B1=E4=BA=8Eselect=E4=B8=AD?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=B2=BE=E8=AF=BB=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E5=AF=BC=E8=87=B4=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=88=AA=E5=8F=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dameng/DamengCodeFirstTest.cs | 69 +++++++++++++++++++ .../DamengCodeFirst.cs | 11 +++ 2 files changed, 80 insertions(+) diff --git a/FreeSql.Tests/FreeSql.Tests/Dameng/DamengCodeFirstTest.cs b/FreeSql.Tests/FreeSql.Tests/Dameng/DamengCodeFirstTest.cs index 01dbc0221..481b51094 100644 --- a/FreeSql.Tests/FreeSql.Tests/Dameng/DamengCodeFirstTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/Dameng/DamengCodeFirstTest.cs @@ -454,5 +454,74 @@ class TableAllType public enum TableAllTypeEnumType1 { e1, e2, e3, e5 } [Flags] public enum TableAllTypeEnumType2 { f1, f2, f3 } + + + + [Fact] + public void UpgradeTableStructure() + { + g.dameng.CodeFirst.SyncStructure(); + + g.dameng.Delete() + .Where(item => 1 == 1) + .ExecuteAffrows(); + + var text = new StringBuilder(); + var temp = "1234567890哈"; + for (int i = 0; i < 3000 - temp.Length; i+= temp.Length) + { + text.Append(temp); + } + + var mode = new TableUpgradeTest + { + Name = "1234560123456012哈哈哈哈哈呵呵_123123", + Text = text.ToString(), + Text2 = "呵呵呵Test123123123" + }; + + mode.Id = g.dameng.Insert(mode) + .ExecuteIdentity(); + + // 第二次进行数据库结果同步 + var sql = g.dameng.CodeFirst.GetComparisonDDLStatements(); + g.dameng.Ado.ExecuteNonQuery(sql); + //g.dameng.CodeFirst.SyncStructure(); + + var resultMode = g.dameng.Select() + .Where(item => item.Id == mode.Id) + .First(); + + Assert.Equal(mode.Name, resultMode?.Name); + Assert.Equal(mode.Text, resultMode?.Text); + Assert.Equal(mode.Text2, resultMode?.Text2); + Assert.Equal(mode.Text3, resultMode?.Text3); + + } + + [Table(Name = "tb_upgrade_test")] + public class TableUpgradeTest + { + [Column(Name = "id", IsPrimary = true, IsIdentity = true)] + public long Id { get; set; } + + + [Column(Name = "name", StringLength = 31, IsNullable = false)] + public string Name { get; set; } + + [Column(Name = "text", StringLength = 32767, IsNullable = false)] + public string Text { get; set; } + + [Column(Name = "number_test", IsNullable = false)] + public int TestNumber { get; set; } + + [Column(Name = "text2", StringLength = 63)] + public string Text2 { get; set; } + + + [Column(Name = "text3")] + public string Text3 { get; set; } + } + } } diff --git a/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs b/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs index 664ddb376..f6142938e 100644 --- a/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs +++ b/Providers/FreeSql.Provider.Dameng/DamengCodeFirst.cs @@ -358,6 +358,17 @@ and a.owner in ({0}) and a.table_name in ({1}) 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 (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) From 54d7679073c538858a20777da8159950623f102d Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Wed, 13 Nov 2024 21:27:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20Firebird=20?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=8F=92=E5=85=A5=20varchar=20=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E7=A9=BA=E6=A0=BC=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?#1923?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Examples/base_entity/Program.cs | 50 +++++++++++-------- FreeSql.DbContext/FreeSql.DbContext.xml | 17 +++++++ .../FirebirdUtils.cs | 1 + 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/Examples/base_entity/Program.cs b/Examples/base_entity/Program.cs index 5c6940483..c22994491 100644 --- a/Examples/base_entity/Program.cs +++ b/Examples/base_entity/Program.cs @@ -574,39 +574,39 @@ static void Main(string[] args) //.UseSlaveWeight(10, 1, 1, 5) - //.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) //.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") - //.UseAdoConnectionPool(false) - //.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2") - ////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2") - //.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) + //.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true") + //.UseAdoConnectionPool(false) + //.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2") + ////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2") + //.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) - //.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2") - //.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) + //.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2") + //.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) - //.UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user=2user;password=123456789;database=2user;poolsize=5;") - //.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) + //.UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user=2user;password=123456789;database=2user;poolsize=5;") + //.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) - //.UseConnectionString(FreeSql.DataType.OdbcMySql, "Driver={MySQL ODBC 8.0 Unicode Driver};Server=127.0.0.1;Persist Security Info=False;Trusted_Connection=Yes;UID=root;PWD=root;DATABASE=cccddd_odbc;Charset=utf8;SslMode=none;Max pool size=2") + //.UseConnectionString(FreeSql.DataType.OdbcMySql, "Driver={MySQL ODBC 8.0 Unicode Driver};Server=127.0.0.1;Persist Security Info=False;Trusted_Connection=Yes;UID=root;PWD=root;DATABASE=cccddd_odbc;Charset=utf8;SslMode=none;Max pool size=2") - //.UseConnectionString(FreeSql.DataType.OdbcSqlServer, "Driver={SQL Server};Server=.;Persist Security Info=False;Trusted_Connection=Yes;Integrated Security=True;DATABASE=freesqlTest_odbc;Pooling=true;Max pool size=3") + //.UseConnectionString(FreeSql.DataType.OdbcSqlServer, "Driver={SQL Server};Server=.;Persist Security Info=False;Trusted_Connection=Yes;Integrated Security=True;DATABASE=freesqlTest_odbc;Pooling=true;Max pool size=3") - //.UseConnectionString(FreeSql.DataType.OdbcPostgreSQL, "Driver={PostgreSQL Unicode(x64)};Server=127.0.0.1;Port=5432;UID=postgres;PWD=123456;Database=tedb_odbc;Pooling=true;Maximum Pool Size=2") - //.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) + //.UseConnectionString(FreeSql.DataType.OdbcPostgreSQL, "Driver={PostgreSQL Unicode(x64)};Server=127.0.0.1;Port=5432;UID=postgres;PWD=123456;Database=tedb_odbc;Pooling=true;Maximum Pool Size=2") + //.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower) - //.UseConnectionString(FreeSql.DataType.OdbcOracle, "Driver={Oracle in XE};Server=//127.0.0.1:1521/XE;Persist Security Info=False;Trusted_Connection=Yes;UID=odbc1;PWD=123456") - //.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper) + //.UseConnectionString(FreeSql.DataType.OdbcOracle, "Driver={Oracle in XE};Server=//127.0.0.1:1521/XE;Persist Security Info=False;Trusted_Connection=Yes;UID=odbc1;PWD=123456") + //.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(DataType.QuestDb, "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;") + //.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.ClickHouse, "DataCompress=False;BufferSize=32768;SocketTimeout=10000;CheckCompressedHash=False;Encrypt=False;Compressor=lz4;Host=192.168.0.121;Port=8125;Database=PersonnelLocation;Username=root;Password=123") + //.UseConnectionString(DataType.ClickHouse, "DataCompress=False;BufferSize=32768;SocketTimeout=10000;CheckCompressedHash=False;Encrypt=False;Compressor=lz4;Host=192.168.0.121;Port=8125;Database=PersonnelLocation;Username=root;Password=123") //.UseConnectionFactory(DataType.ClickHouse, () => null) - .UseMonitorCommand(cmd => + .UseMonitorCommand(cmd => { Console.WriteLine(cmd.CommandText + "\r\n"); //cmd.CommandText = null; //不执行 @@ -619,6 +619,16 @@ static void Main(string[] args) BaseEntity.Initialization(fsql, () => _asyncUow.Value); #endregion + fsql.Delete().Where("1=1").ExecuteAffrows(); + fsql.Insert(new List + { + new User1 { Nickname = "nickname11", Username = "username11", Description = "desc11" }, + new User1 { Nickname = "n2", Username = "u2", Description = "d2" }, + new User1 { Nickname = "n3", Username = "u3", Description = "d3" }, + }).ExecuteAffrows(); + + var firebirdList01 = fsql.Select().ToList(); + fsql.UseJsonMap(); fsql.Select().Where(a => a.Options.Value1 == 100 && a.Options.Value2 == "xx").ToList(); diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml index 08ab7dc4c..c941a15d9 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.xml +++ b/FreeSql.DbContext/FreeSql.DbContext.xml @@ -712,6 +712,15 @@ + + + 根据Assembly扫描所有继承IEntityTypeConfiguration<T>的配置类 + + + + + + 创建普通数据上下文档对象 @@ -749,5 +758,13 @@ + + + 批量注入 Repository,可以参考代码自行调整 + + + + + diff --git a/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs b/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs index e9162b893..78afb25db 100644 --- a/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs +++ b/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs @@ -89,6 +89,7 @@ public override string GetNoneParamaterSqlValue(List specialParams, if (value == null) return "NULL"; if (type.IsNumberType()) return string.Format(CultureInfo.InvariantCulture, "{0}", value); if (type == typeof(byte[])) return $"x'{CommonUtils.BytesSqlRaw(value as byte[])}'"; + if (type == typeof(string) && (specialParamFlag == "c" || specialParamFlag == "cu")) return $"cast('{value.ToString().Replace("'", "''")}' as varchar({col.DbSize}))"; //#1923 return FormatSql("{0}", value, 1); } } From 78415d83b84c2c2ea9cf869038576b2233966955 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Wed, 13 Nov 2024 21:36:29 +0800 Subject: [PATCH 3/3] v3.5.100-preview20241113 #1923 #1922 --- Directory.Build.props | 2 +- .../FreeSql.Extensions.AggregateRoot.csproj | 2 +- .../FreeSql.Extensions.BaseEntity.csproj | 2 +- .../FreeSql.Extensions.JsonMap.csproj | 2 +- .../FreeSql.Extensions.LazyLoading.csproj | 2 +- .../FreeSql.Extensions.Linq.csproj | 2 +- .../FreeSql.Extensions.ZeroEntity.csproj | 2 +- .../FreeSql.Generator.csproj | 2 +- FreeSql.All/FreeSql.All.csproj | 2 +- FreeSql.DbContext/FreeSql.DbContext.csproj | 2 +- FreeSql.DbContext/FreeSql.DbContext.xml | 8 - FreeSql.Repository/FreeSql.Repository.csproj | 2 +- FreeSql/FreeSql.csproj | 2 +- FreeSql/FreeSql.xml | 232 ++++++++++-------- .../FreeSql.Provider.ClickHouse.csproj | 2 +- .../FreeSql.Provider.Custom.csproj | 2 +- .../FreeSql.Provider.Dameng.csproj | 2 +- .../FreeSql.Provider.Duckdb.csproj | 2 +- .../FirebirdUtils.cs | 2 +- .../FreeSql.Provider.Firebird.csproj | 2 +- .../FreeSql.Provider.GBase.csproj | 2 +- .../FreeSql.Provider.KingbaseES.csproj | 2 +- .../FreeSql.Provider.MsAccess.csproj | 2 +- .../FreeSql.Provider.MySql.csproj | 2 +- .../FreeSql.Provider.MySqlConnector.csproj | 2 +- .../FreeSql.Provider.Odbc.csproj | 2 +- .../FreeSql.Provider.Oracle.csproj | 2 +- .../FreeSql.Provider.OracleOledb.csproj | 2 +- .../FreeSql.Provider.PostgreSQL.csproj | 2 +- .../FreeSql.Provider.QuestDb.csproj | 2 +- .../FreeSql.Provider.ShenTong.csproj | 2 +- .../FreeSql.Provider.SqlServer.csproj | 2 +- ...FreeSql.Provider.SqlServerForSystem.csproj | 2 +- .../FreeSql.Provider.Sqlite.csproj | 2 +- .../FreeSql.Provider.SqliteCore.csproj | 2 +- .../FreeSql.Provider.Xugu.csproj | 2 +- 36 files changed, 157 insertions(+), 151 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index eec0d5d64..7db6e7191 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ diff --git a/Extensions/FreeSql.Extensions.AggregateRoot/FreeSql.Extensions.AggregateRoot.csproj b/Extensions/FreeSql.Extensions.AggregateRoot/FreeSql.Extensions.AggregateRoot.csproj index 959e2485d..6581dff69 100644 --- a/Extensions/FreeSql.Extensions.AggregateRoot/FreeSql.Extensions.AggregateRoot.csproj +++ b/Extensions/FreeSql.Extensions.AggregateRoot/FreeSql.Extensions.AggregateRoot.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.csproj b/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.csproj index 914220042..ce12c130c 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.csproj +++ b/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.csproj @@ -19,7 +19,7 @@ key.snk false latest - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Extensions/FreeSql.Extensions.JsonMap/FreeSql.Extensions.JsonMap.csproj b/Extensions/FreeSql.Extensions.JsonMap/FreeSql.Extensions.JsonMap.csproj index c47fad275..937570027 100644 --- a/Extensions/FreeSql.Extensions.JsonMap/FreeSql.Extensions.JsonMap.csproj +++ b/Extensions/FreeSql.Extensions.JsonMap/FreeSql.Extensions.JsonMap.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Extensions/FreeSql.Extensions.LazyLoading/FreeSql.Extensions.LazyLoading.csproj b/Extensions/FreeSql.Extensions.LazyLoading/FreeSql.Extensions.LazyLoading.csproj index 82d1d36c4..381868ecc 100644 --- a/Extensions/FreeSql.Extensions.LazyLoading/FreeSql.Extensions.LazyLoading.csproj +++ b/Extensions/FreeSql.Extensions.LazyLoading/FreeSql.Extensions.LazyLoading.csproj @@ -15,7 +15,7 @@ $(AssemblyName) true true - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Extensions/FreeSql.Extensions.Linq/FreeSql.Extensions.Linq.csproj b/Extensions/FreeSql.Extensions.Linq/FreeSql.Extensions.Linq.csproj index 1d44e81fe..227fb1e41 100644 --- a/Extensions/FreeSql.Extensions.Linq/FreeSql.Extensions.Linq.csproj +++ b/Extensions/FreeSql.Extensions.Linq/FreeSql.Extensions.Linq.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Extensions/FreeSql.Extensions.ZeroEntity/FreeSql.Extensions.ZeroEntity.csproj b/Extensions/FreeSql.Extensions.ZeroEntity/FreeSql.Extensions.ZeroEntity.csproj index 782026f35..8770ab876 100644 --- a/Extensions/FreeSql.Extensions.ZeroEntity/FreeSql.Extensions.ZeroEntity.csproj +++ b/Extensions/FreeSql.Extensions.ZeroEntity/FreeSql.Extensions.ZeroEntity.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Extensions/FreeSql.Generator/FreeSql.Generator.csproj b/Extensions/FreeSql.Generator/FreeSql.Generator.csproj index 633ac69a4..6c8e04278 100644 --- a/Extensions/FreeSql.Generator/FreeSql.Generator.csproj +++ b/Extensions/FreeSql.Generator/FreeSql.Generator.csproj @@ -13,7 +13,7 @@ https://github.com/2881099/FreeSql https://github.com/2881099/FreeSql FreeSql DbFirst 实体生成器 - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/FreeSql.All/FreeSql.All.csproj b/FreeSql.All/FreeSql.All.csproj index 2f26bf41c..46b55b9f8 100644 --- a/FreeSql.All/FreeSql.All.csproj +++ b/FreeSql.All/FreeSql.All.csproj @@ -17,7 +17,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/FreeSql.DbContext/FreeSql.DbContext.csproj b/FreeSql.DbContext/FreeSql.DbContext.csproj index ab22b885f..ba90924e9 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.csproj +++ b/FreeSql.DbContext/FreeSql.DbContext.csproj @@ -17,7 +17,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml index c941a15d9..a7a94fcda 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.xml +++ b/FreeSql.DbContext/FreeSql.DbContext.xml @@ -758,13 +758,5 @@ - - - 批量注入 Repository,可以参考代码自行调整 - - - - - diff --git a/FreeSql.Repository/FreeSql.Repository.csproj b/FreeSql.Repository/FreeSql.Repository.csproj index 9175718c4..e885fc124 100644 --- a/FreeSql.Repository/FreeSql.Repository.csproj +++ b/FreeSql.Repository/FreeSql.Repository.csproj @@ -17,7 +17,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/FreeSql/FreeSql.csproj b/FreeSql/FreeSql.csproj index 0a939f024..0eff1a6e3 100644 --- a/FreeSql/FreeSql.csproj +++ b/FreeSql/FreeSql.csproj @@ -17,7 +17,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 8e9e51672..fdde4800e 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -1087,93 +1087,6 @@ - - - 动态创建实体类型 - - - - - 配置Class - - 类名 - 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] - - - - - 获取类型构建器,可作为要构建的Type来引用 - - - - - 配置属性 - - 属性名称 - 属性类型 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性默认值 - 属性标记的特性-支持多个 - - - - - 配置父类 - - 父类类型 - - - - - Override属性 - - - - - - Emit动态创建出Class - Type - - - - - - Emit动态创建出Class - Type,不附带获取TableInfo - - - - - - 首字母小写 - - - - - - - 首字母大写 - - - - 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 "" @@ -5897,28 +5810,6 @@ 对象池 - - - 动态构建Class Type - - - - - - 根据字典,创建 table 对应的实体对象 - - - - - - - - 根据实体对象,创建 table 对应的字典 - - - - - C#: that >= between && that <= and @@ -6455,3 +6346,126 @@ + + + + + 插入数据,传入实体集合 + + + + + + + + 插入数据,传入实体集合 + + + + + + + + 插入或更新数据,此功能依赖数据库特性(低版本可能不支持),参考如下: + MySql 5.6+: on duplicate key update + PostgreSQL 9.4+: on conflict do update + SqlServer 2008+: merge into + Oracle 11+: merge into + Sqlite: replace into + DuckDB: on conflict do update + 达梦: merge into + 人大金仓:on conflict do update + 神通:merge into + MsAccess:不支持 + 注意区别:FreeSql.Repository 仓储也有 InsertOrUpdate 方法(不依赖数据库特性) + + + + + + + 修改数据 + + + + + + + 修改数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 查询数据 + + + + + + + 查询数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 删除数据 + + + + + + + 删除数据,传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} + + + 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 + + + + + 开启事务(不支持异步) + v1.5.0 关闭了线程事务超时自动提交的机制 + + 事务体 () => {} + + + + 开启事务(不支持异步) + v1.5.0 关闭了线程事务超时自动提交的机制 + + + 事务体 () => {} + + + + 数据库访问对象 + + + + + 所有拦截方法都在这里 + + + + + CodeFirst 模式开发相关方法 + + + + + DbFirst 模式开发相关方法 + + + + + 全局过滤设置,可默认附加为 Select/Update/Delete 条件 + + + + diff --git a/Providers/FreeSql.Provider.ClickHouse/FreeSql.Provider.ClickHouse.csproj b/Providers/FreeSql.Provider.ClickHouse/FreeSql.Provider.ClickHouse.csproj index 0c5faa0ad..d6a582082 100644 --- a/Providers/FreeSql.Provider.ClickHouse/FreeSql.Provider.ClickHouse.csproj +++ b/Providers/FreeSql.Provider.ClickHouse/FreeSql.Provider.ClickHouse.csproj @@ -19,7 +19,7 @@ False key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Custom/FreeSql.Provider.Custom.csproj b/Providers/FreeSql.Provider.Custom/FreeSql.Provider.Custom.csproj index a7df78a8c..ae5fbbb08 100644 --- a/Providers/FreeSql.Provider.Custom/FreeSql.Provider.Custom.csproj +++ b/Providers/FreeSql.Provider.Custom/FreeSql.Provider.Custom.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Dameng/FreeSql.Provider.Dameng.csproj b/Providers/FreeSql.Provider.Dameng/FreeSql.Provider.Dameng.csproj index e2c2e0c9c..4d50cd7b4 100644 --- a/Providers/FreeSql.Provider.Dameng/FreeSql.Provider.Dameng.csproj +++ b/Providers/FreeSql.Provider.Dameng/FreeSql.Provider.Dameng.csproj @@ -15,7 +15,7 @@ $(AssemblyName) true true - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Duckdb/FreeSql.Provider.Duckdb.csproj b/Providers/FreeSql.Provider.Duckdb/FreeSql.Provider.Duckdb.csproj index 21a27de35..b60510758 100644 --- a/Providers/FreeSql.Provider.Duckdb/FreeSql.Provider.Duckdb.csproj +++ b/Providers/FreeSql.Provider.Duckdb/FreeSql.Provider.Duckdb.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs b/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs index 78afb25db..d58f14eee 100644 --- a/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs +++ b/Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs @@ -89,7 +89,7 @@ public override string GetNoneParamaterSqlValue(List specialParams, if (value == null) return "NULL"; if (type.IsNumberType()) return string.Format(CultureInfo.InvariantCulture, "{0}", value); if (type == typeof(byte[])) return $"x'{CommonUtils.BytesSqlRaw(value as byte[])}'"; - if (type == typeof(string) && (specialParamFlag == "c" || specialParamFlag == "cu")) return $"cast('{value.ToString().Replace("'", "''")}' as varchar({col.DbSize}))"; //#1923 + if (type == typeof(string) && col != null && (specialParamFlag == "c" || specialParamFlag == "cu")) return $"cast('{value.ToString().Replace("'", "''")}' as {col.Attribute.DbType})"; //#1923 return FormatSql("{0}", value, 1); } } diff --git a/Providers/FreeSql.Provider.Firebird/FreeSql.Provider.Firebird.csproj b/Providers/FreeSql.Provider.Firebird/FreeSql.Provider.Firebird.csproj index 0fa9176aa..fb9892b16 100644 --- a/Providers/FreeSql.Provider.Firebird/FreeSql.Provider.Firebird.csproj +++ b/Providers/FreeSql.Provider.Firebird/FreeSql.Provider.Firebird.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.GBase/FreeSql.Provider.GBase.csproj b/Providers/FreeSql.Provider.GBase/FreeSql.Provider.GBase.csproj index 0b3d636ec..c3d1bb37c 100644 --- a/Providers/FreeSql.Provider.GBase/FreeSql.Provider.GBase.csproj +++ b/Providers/FreeSql.Provider.GBase/FreeSql.Provider.GBase.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.KingbaseES/FreeSql.Provider.KingbaseES.csproj b/Providers/FreeSql.Provider.KingbaseES/FreeSql.Provider.KingbaseES.csproj index 861a03b0a..34d74d719 100644 --- a/Providers/FreeSql.Provider.KingbaseES/FreeSql.Provider.KingbaseES.csproj +++ b/Providers/FreeSql.Provider.KingbaseES/FreeSql.Provider.KingbaseES.csproj @@ -15,7 +15,7 @@ $(AssemblyName) true true - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.MsAccess/FreeSql.Provider.MsAccess.csproj b/Providers/FreeSql.Provider.MsAccess/FreeSql.Provider.MsAccess.csproj index 0e77a1b31..55890cc22 100644 --- a/Providers/FreeSql.Provider.MsAccess/FreeSql.Provider.MsAccess.csproj +++ b/Providers/FreeSql.Provider.MsAccess/FreeSql.Provider.MsAccess.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.MySql/FreeSql.Provider.MySql.csproj b/Providers/FreeSql.Provider.MySql/FreeSql.Provider.MySql.csproj index dcf02127e..d9527bed9 100644 --- a/Providers/FreeSql.Provider.MySql/FreeSql.Provider.MySql.csproj +++ b/Providers/FreeSql.Provider.MySql/FreeSql.Provider.MySql.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.MySqlConnector/FreeSql.Provider.MySqlConnector.csproj b/Providers/FreeSql.Provider.MySqlConnector/FreeSql.Provider.MySqlConnector.csproj index af6ebd26d..2d31ddb6d 100644 --- a/Providers/FreeSql.Provider.MySqlConnector/FreeSql.Provider.MySqlConnector.csproj +++ b/Providers/FreeSql.Provider.MySqlConnector/FreeSql.Provider.MySqlConnector.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Odbc/FreeSql.Provider.Odbc.csproj b/Providers/FreeSql.Provider.Odbc/FreeSql.Provider.Odbc.csproj index f57e11fa4..04e826c6d 100644 --- a/Providers/FreeSql.Provider.Odbc/FreeSql.Provider.Odbc.csproj +++ b/Providers/FreeSql.Provider.Odbc/FreeSql.Provider.Odbc.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Oracle/FreeSql.Provider.Oracle.csproj b/Providers/FreeSql.Provider.Oracle/FreeSql.Provider.Oracle.csproj index 3e06a9924..b1c754c5b 100644 --- a/Providers/FreeSql.Provider.Oracle/FreeSql.Provider.Oracle.csproj +++ b/Providers/FreeSql.Provider.Oracle/FreeSql.Provider.Oracle.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.OracleOledb/FreeSql.Provider.OracleOledb.csproj b/Providers/FreeSql.Provider.OracleOledb/FreeSql.Provider.OracleOledb.csproj index 8db8fbb59..b90959036 100644 --- a/Providers/FreeSql.Provider.OracleOledb/FreeSql.Provider.OracleOledb.csproj +++ b/Providers/FreeSql.Provider.OracleOledb/FreeSql.Provider.OracleOledb.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.PostgreSQL/FreeSql.Provider.PostgreSQL.csproj b/Providers/FreeSql.Provider.PostgreSQL/FreeSql.Provider.PostgreSQL.csproj index ab0b78de6..834a72d8a 100644 --- a/Providers/FreeSql.Provider.PostgreSQL/FreeSql.Provider.PostgreSQL.csproj +++ b/Providers/FreeSql.Provider.PostgreSQL/FreeSql.Provider.PostgreSQL.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.QuestDb/FreeSql.Provider.QuestDb.csproj b/Providers/FreeSql.Provider.QuestDb/FreeSql.Provider.QuestDb.csproj index db60e9715..3fa8114bb 100644 --- a/Providers/FreeSql.Provider.QuestDb/FreeSql.Provider.QuestDb.csproj +++ b/Providers/FreeSql.Provider.QuestDb/FreeSql.Provider.QuestDb.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.ShenTong/FreeSql.Provider.ShenTong.csproj b/Providers/FreeSql.Provider.ShenTong/FreeSql.Provider.ShenTong.csproj index 09ef34bdc..4d98e7a0f 100644 --- a/Providers/FreeSql.Provider.ShenTong/FreeSql.Provider.ShenTong.csproj +++ b/Providers/FreeSql.Provider.ShenTong/FreeSql.Provider.ShenTong.csproj @@ -15,7 +15,7 @@ $(AssemblyName) true true - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.SqlServer/FreeSql.Provider.SqlServer.csproj b/Providers/FreeSql.Provider.SqlServer/FreeSql.Provider.SqlServer.csproj index b8e77a337..3c4130b6f 100644 --- a/Providers/FreeSql.Provider.SqlServer/FreeSql.Provider.SqlServer.csproj +++ b/Providers/FreeSql.Provider.SqlServer/FreeSql.Provider.SqlServer.csproj @@ -18,7 +18,7 @@ true false key.snk - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.SqlServerForSystem/FreeSql.Provider.SqlServerForSystem.csproj b/Providers/FreeSql.Provider.SqlServerForSystem/FreeSql.Provider.SqlServerForSystem.csproj index b0160ad42..731901075 100644 --- a/Providers/FreeSql.Provider.SqlServerForSystem/FreeSql.Provider.SqlServerForSystem.csproj +++ b/Providers/FreeSql.Provider.SqlServerForSystem/FreeSql.Provider.SqlServerForSystem.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Sqlite/FreeSql.Provider.Sqlite.csproj b/Providers/FreeSql.Provider.Sqlite/FreeSql.Provider.Sqlite.csproj index 4f8d23f01..bd86071be 100644 --- a/Providers/FreeSql.Provider.Sqlite/FreeSql.Provider.Sqlite.csproj +++ b/Providers/FreeSql.Provider.Sqlite/FreeSql.Provider.Sqlite.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.SqliteCore/FreeSql.Provider.SqliteCore.csproj b/Providers/FreeSql.Provider.SqliteCore/FreeSql.Provider.SqliteCore.csproj index 627cd1045..a9f4cd1e6 100644 --- a/Providers/FreeSql.Provider.SqliteCore/FreeSql.Provider.SqliteCore.csproj +++ b/Providers/FreeSql.Provider.SqliteCore/FreeSql.Provider.SqliteCore.csproj @@ -18,7 +18,7 @@ true key.snk false - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md diff --git a/Providers/FreeSql.Provider.Xugu/FreeSql.Provider.Xugu.csproj b/Providers/FreeSql.Provider.Xugu/FreeSql.Provider.Xugu.csproj index 0cd265936..aafabf6b2 100644 --- a/Providers/FreeSql.Provider.Xugu/FreeSql.Provider.Xugu.csproj +++ b/Providers/FreeSql.Provider.Xugu/FreeSql.Provider.Xugu.csproj @@ -15,7 +15,7 @@ $(AssemblyName) true true - 3.5.100-preview20241112 + 3.5.100-preview20241113 readme.md