From 59a3069db7cb8262b6c110176e8b954f591f9ad4 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Tue, 22 Oct 2024 14:13:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=AA.net=208.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.dcproj | 1 + docker-compose.yml | 3 ++- .../IoTSharp.EntityFrameworkCore.Taos.csproj | 14 +++++------ .../Conventions/TaosAttributeConvention.cs | 2 +- .../Migrations/TaosMigrationsSqlGenerator.cs | 4 ++-- .../Query/Internal/TaosQuerySqlGenerator.cs | 5 ++-- .../Update/Internal/TaosUpdateSqlGenerator.cs | 16 ++++++------- .../EntityFrameworkCore.Taos.Tests.csproj | 24 +++++++++++++++---- .../SqModelTest.cs | 12 +++++----- src/Example/Dockerfile | 2 +- src/Example/Example.csproj | 8 +++---- src/Example/Program.cs | 8 +++---- .../IoTSharp.Data.Taos.csproj | 2 +- .../Protocols/TDRESTful/TaosRESTful.cs | 7 ++++-- .../IoTSharp.HealthChecks.Taos.csproj | 4 ++-- 15 files changed, 66 insertions(+), 46 deletions(-) diff --git a/docker-compose.dcproj b/docker-compose.dcproj index de80b95..ba99221 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -14,5 +14,6 @@ + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c8f91d2..a5b2e84 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: - taos-network taos: - image: tdengine/tdengine:3.2.1.0 + image: tdengine/tdengine:3.3.3.0 restart: always hostname: taos volumes: @@ -23,6 +23,7 @@ services: - 6030:6030 - 6035:6035 - 6041:6041 + - 6043:6043 - 6030-6040:6030-6040/udp networks: - taos-network diff --git a/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj b/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj index f16f8e7..206a744 100644 --- a/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj +++ b/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj @@ -3,7 +3,7 @@ TaosData database provider for Entity Framework Core. - net6.0 + net8.0 true Maikebing true @@ -15,7 +15,7 @@ Maikebing.EntityFrameworkCore.Taos 是一个Entity Framework Core 的提供器, 基于Maikebing.Data.Taos构建。 LICENSE - Copyright © 2019-2023 IoTSharp All rights reserved. + Copyright © 2019-2024 IoTSharp All rights reserved. 1.0.1 Taos;Data;ADO.NET;Entity Framework;EF; Core;Data O/RM;entity-framework-core;TDengine AnyCPU;x64;x86 @@ -25,14 +25,14 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/EFCore.Taos.Core/Metadata/Conventions/TaosAttributeConvention.cs b/src/EFCore.Taos.Core/Metadata/Conventions/TaosAttributeConvention.cs index 9de8d07..c201385 100644 --- a/src/EFCore.Taos.Core/Metadata/Conventions/TaosAttributeConvention.cs +++ b/src/EFCore.Taos.Core/Metadata/Conventions/TaosAttributeConvention.cs @@ -12,7 +12,7 @@ // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { - public class TaosAttributeConvention : EntityTypeAttributeConventionBase + public class TaosAttributeConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.TypeAttributeConventionBase { public TaosAttributeConvention(ProviderConventionSetBuilderDependencies dependencies) : base(dependencies) { diff --git a/src/EFCore.Taos.Core/Migrations/TaosMigrationsSqlGenerator.cs b/src/EFCore.Taos.Core/Migrations/TaosMigrationsSqlGenerator.cs index 6b3ea6d..2b864f4 100644 --- a/src/EFCore.Taos.Core/Migrations/TaosMigrationsSqlGenerator.cs +++ b/src/EFCore.Taos.Core/Migrations/TaosMigrationsSqlGenerator.cs @@ -324,7 +324,7 @@ protected override void Generate( var table = model?.GetRelationalModel().FindTable(operation.Name, operation.Schema); - var mt = table.EntityTypeMappings.FirstOrDefault().EntityType.ClrType; + var mt = table.EntityTypeMappings.FirstOrDefault().TypeBase.ClrType; var tabInfo = mt.GetCustomAttribute(); var isSupertable = tabInfo?.IsSuperTable ?? false; //IColumn column = table?.FindColumn(operation.Name); @@ -404,7 +404,7 @@ private void CreateTableColumnsWithComments( MigrationCommandListBuilder builder) { var table = model?.GetRelationalModel().FindTable(operation.Name, null); - var mt = table.EntityTypeMappings.FirstOrDefault().EntityType.ClrType; + var mt = table.EntityTypeMappings.FirstOrDefault().TypeBase.ClrType; var propInfos = mt.GetProperties() .Select(s => (propertyInfo: s, Info: s.GetCustomAttribute())) .Where(w => w.Info != null) diff --git a/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs b/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs index ecddc34..e8f2446 100644 --- a/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs +++ b/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs @@ -106,7 +106,7 @@ protected override Expression VisitSqlConstant(SqlConstantExpression sqlConstant { return base.VisitSqlConstant(sqlConstantExpression); } - protected override Expression VisitLike(LikeExpression likeExpression) + protected override void GenerateLike(LikeExpression likeExpression, bool negated) { Visit(likeExpression.Match); this.Sql.Append(" LIKE "); @@ -117,8 +117,7 @@ protected override Expression VisitLike(LikeExpression likeExpression) this.Sql.Append(" ESCAPE "); Visit(likeExpression.EscapeChar); } - - return likeExpression; } + } } diff --git a/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs b/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs index a67077f..df35281 100644 --- a/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs +++ b/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs @@ -213,20 +213,20 @@ protected void AppendInsertCommand( { var tableMap = command.Table.EntityTypeMappings.FirstOrDefault(f => { - var attr = f.EntityType.ClrType.GetCustomAttribute(); + var attr = f.TypeBase.ClrType.GetCustomAttribute(); if (attr != null && !string.IsNullOrEmpty(attr.TableName)) { return attr.TableName == command.TableName; } - return f.EntityType.ClrType.Name == command.TableName; + return f.TypeBase. ClrType.Name == command.TableName; }); var isSupperTable = false; var subTableName = string.Empty; - var propertyAttrMaps = tableMap.EntityType.ClrType.GetProperties().Select(s => (PropertyInfo: s, Attr: s.GetCustomAttribute())).ToList(); + var propertyAttrMaps = tableMap.TypeBase.ClrType.GetProperties().Select(s => (PropertyInfo: s, Attr: s.GetCustomAttribute())).ToList(); if (tableMap != null) { - var taosAttr = tableMap.EntityType.ClrType.GetCustomAttribute(); + var taosAttr = tableMap.TypeBase.ClrType.GetCustomAttribute(); if (taosAttr != null) { isSupperTable = taosAttr.IsSuperTable; @@ -399,20 +399,20 @@ protected void AppendInsertCommandHeader( { var tableMap = command.Table.EntityTypeMappings.FirstOrDefault(f => { - var attr = f.EntityType.ClrType.GetCustomAttribute(); + var attr = f.TypeBase.ClrType.GetCustomAttribute(); if (attr != null && !string.IsNullOrEmpty(attr.TableName)) { return attr.TableName == command.TableName; } - return f.EntityType.ClrType.Name == command.TableName; + return f.TypeBase.ClrType.Name == command.TableName; }); var isSupperTable = false; var subTableName = string.Empty; - var propertyAttrMaps = tableMap.EntityType.ClrType.GetProperties().Select(s => (PropertyInfo: s, Attr: s.GetCustomAttribute())).ToList(); + var propertyAttrMaps = tableMap.TypeBase.ClrType.GetProperties().Select(s => (PropertyInfo: s, Attr: s.GetCustomAttribute())).ToList(); if (tableMap != null) { - var taosAttr = tableMap.EntityType.ClrType.GetCustomAttribute(); + var taosAttr = tableMap.TypeBase.ClrType.GetCustomAttribute(); if (taosAttr != null) { isSupperTable = taosAttr.IsSuperTable; diff --git a/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj b/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj index b6b1fe2..ba37319 100644 --- a/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj +++ b/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj @@ -1,20 +1,36 @@  - net6.0 + net8.0 false + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs b/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs index 789f8a7..eaef1ed 100644 --- a/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs +++ b/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs @@ -25,15 +25,15 @@ public void TestExecuteBulkInsert_Json() var s2 = SelectQueryParser.Parse(SQLDemo2); Assert.AreEqual(5, ((int?)s2.Parameters?.Count).GetValueOrDefault()); - Assert.AreEqual("@p1", s2.Parameters?.Keys.ToArray()[0]); + Assert.AreEqual("@p1", s2.Parameters.FirstOrDefault()?.ParameterName); var pn2 = s2.Parameters; Assert.AreEqual(1, pn2.Count); - Assert.AreEqual("@p1", pn2.Keys.ToArray()[0]); + Assert.AreEqual("@p1", pn2.FirstOrDefault()?.ParameterName); var s3 = SelectQueryParser.Parse(SQLDemo3); Assert.AreEqual(7, s3.Parameters?.Count); - Assert.AreEqual("@t1", s3.Parameters?.ToArray()[1].Key); - Assert.AreEqual("@t11", s3.Parameters?.ToArray()[3].Key); + Assert.AreEqual("@t1", s3.Parameters[1].ParameterName); + Assert.AreEqual("@t11", s3.Parameters[3].ParameterName); // Assert.AreEqual(" LIMIT ",s3.); //Assert.AreEqual("@t3", s3[5].OriginalText); //Assert.AreEqual(";", s3[6].OriginalText); @@ -60,8 +60,8 @@ public void TestExecuteBulkInsert_Json() var s5 = SelectQueryParser.Parse("insert into #subtable using stable tags($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$t12,$t13) values (@t1,@t2,@t3,@t4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14)"); Assert.AreEqual(14, s5.Parameters?.Count); - Assert.AreEqual("#subtable", s5.Parameters?.ToArray()[0].Key); - Assert.AreEqual(13, s5.Parameters?.Count(k=>k.Key.StartsWith('$'))); + Assert.AreEqual("#subtable", s5.Parameters?.FirstOrDefault()?.ParameterName); + Assert.AreEqual(13, s5.Parameters.Count(k=>k.ParameterName.StartsWith('$'))); // Assert.AreEqual("insert into ? using stable tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", s4.CommandText); } diff --git a/src/Example/Dockerfile b/src/Example/Dockerfile index 976ad5b..c4a0797 100644 --- a/src/Example/Dockerfile +++ b/src/Example/Dockerfile @@ -7,7 +7,7 @@ RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free" >> /etc/apt/sources.list && \ apt-get -y -q update && apt-get install -y --no-install-recommends -q apt-utils lsof net-tools wget curl iputils-ping inetutils-tools && \ apt-get autoremove -y && apt-get clean && apt-get autoclean && rm /var/cache/apt/* -rf && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -RUN curl -o TDengine-client.tar.gz "https://www.taosdata.com/assets-download/3.0/TDengine-client-3.2.1.0-Linux-x64.tar.gz" && \ +RUN curl -o TDengine-client.tar.gz "https://www.taosdata.com/assets-download/3.0/TDengine-client-3.3.3.0-Linux-x64.tar.gz" && \ tar -xvf TDengine-client.tar.gz && rm TDengine-client.tar.gz -f && cd $(ls TDengine-client* -d) && \ ./install_client.sh && \ rm $(pwd) -rf diff --git a/src/Example/Example.csproj b/src/Example/Example.csproj index 19838ce..64aa804 100644 --- a/src/Example/Example.csproj +++ b/src/Example/Example.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 Maikebing Linux ..\.. @@ -10,9 +10,9 @@ - - - + + + diff --git a/src/Example/Program.cs b/src/Example/Program.cs index 7bb4742..96101de 100644 --- a/src/Example/Program.cs +++ b/src/Example/Program.cs @@ -45,7 +45,7 @@ private static void Main(string[] args) { //issue259_258(); var IS_RUNNING_IN_CONTAINER = bool.TryParse(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), out bool _DOTNET_RUNNING_IN_CONTAINER) && _DOTNET_RUNNING_IN_CONTAINER; - var _dbhost = "172.16.0.189";// IS_RUNNING_IN_CONTAINER ? "taos" : System.Net.Dns.GetHostName(); + var _dbhost = IS_RUNNING_IN_CONTAINER ? "taos" : System.Net.Dns.GetHostName(); Console.WriteLine($"主机名:{_dbhost} 当前程序运行在{(IS_RUNNING_IN_CONTAINER ? "容器内" : "主机中")} "); Console.WriteLine($"CPU:{Environment.ProcessorCount} 主机名:{Environment.MachineName}"); var p = new Ping(); @@ -60,13 +60,13 @@ private static void Main(string[] args) DataSource = _dbhost, DataBase = database, Username = "root", - Password = "astop.123", + Password = "taosdata", Port = 6030, ConnectionTimeout = 10000, - PoolSize = 20000 + PoolSize = 20 }; builder.ConnectionTimeout = 10000; - UseTaosEFCore(builder.UseRESTful()); + UseTaosEFCore(builder.UseNative()); var builder_cloud = new TaosConnectionStringBuilder() { diff --git a/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj b/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj index 31dbd69..e06c92d 100644 --- a/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj +++ b/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj @@ -16,7 +16,7 @@ IoTSharp.Data.Taos.TaosParameter IoTSharp.Data.Taos.TaosTransaction - net6;net7;net8;net4.6;netstandard2.0 + net6;net8;net4.6;netstandard2.0 10 Taos;Data;ADO.NET;Entity Framework,;EF; Core;Data O/RM,;entity-framework-core;TDengine;IoTSharp Yanhong Ma diff --git a/src/IoTSharp.Data.Taos/Protocols/TDRESTful/TaosRESTful.cs b/src/IoTSharp.Data.Taos/Protocols/TDRESTful/TaosRESTful.cs index 47f003b..1461e21 100644 --- a/src/IoTSharp.Data.Taos/Protocols/TDRESTful/TaosRESTful.cs +++ b/src/IoTSharp.Data.Taos/Protocols/TDRESTful/TaosRESTful.cs @@ -130,8 +130,11 @@ public TaosDataReader ExecuteReader(CommandBehavior behavior, TaosCommand comman private TaosResult Execute(string _commandText) { - var cmdPackage = CombineCommandPackage.CreatePackage(_commandText, this); - return cmdPackage.ExeTask.Result; + + var cmdPackage = CombineCommandPackage.CreatePackage(_commandText, this); + Debug.Assert(_commandText != "create database if not exists ntest"); + return cmdPackage.ExeTask.Result; + } diff --git a/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj b/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj index aeb973a..77f18a2 100644 --- a/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj +++ b/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj @@ -17,8 +17,8 @@ - - + +