瀏覽代碼

freestyle optimize

Lith 10 月之前
父節點
當前提交
a3dee47961
共有 54 個文件被更改,包括 138 次插入120 次删除
  1. 14 0
      Vitorm.sln
  2. 9 7
      src/Vitorm.Data/Data.cs
  3. 1 1
      src/Vitorm.Data/Vitorm.Data.csproj
  4. 1 1
      src/Vitorm.MySql/SqlTransactionScope.cs
  5. 5 4
      src/Vitorm.MySql/SqlTransactionScope_Command.cs
  6. 2 1
      src/Vitorm.MySql/SqlTranslateService.cs
  7. 2 3
      src/Vitorm.SqlServer/SqlTransactionScope.cs
  8. 3 3
      src/Vitorm.SqlServer/SqlTranslate/QueryTranslateService.cs
  9. 1 1
      src/Vitorm.SqlServer/SqlTranslateService.cs
  10. 2 3
      src/Vitorm.Sqlite/SqlTransactionScope.cs
  11. 1 1
      src/Vitorm.Sqlite/SqlTranslateService.cs
  12. 1 1
      src/Vitorm/DbSet.cs
  13. 1 1
      src/Vitorm/Entity/DataAnnotations/ColumnDescriptor.cs
  14. 2 1
      src/Vitorm/Entity/Loader/DefaultEntityLoader.cs
  15. 1 0
      src/Vitorm/Entity/LoaderAttribute/EntityLoaderFromAttribute.cs
  16. 3 2
      src/Vitorm/Sql/DataReader/EntityReader.cs
  17. 1 2
      src/Vitorm/Sql/DataReader/EntityReader/ModelReader.cs
  18. 1 1
      src/Vitorm/Sql/DataReader/EntityReader/SqlFieldReader.cs
  19. 1 3
      src/Vitorm/Sql/DataReader/FirstEntityReader.cs
  20. 1 1
      src/Vitorm/Sql/IDbDataReader.cs
  21. 1 2
      src/Vitorm/Sql/SqlDbContext.cs
  22. 5 5
      src/Vitorm/Sql/SqlTranslate/BaseQueryTranslateService.cs
  23. 1 1
      src/Vitorm/Sql/SqlTranslate/IQueryTranslateService.cs
  24. 2 2
      src/Vitorm/Sql/SqlTranslate/ISqlTranslateService.cs
  25. 1 4
      src/Vitorm/Sql/SqlTranslate/QueryTranslateArgument.cs
  26. 4 3
      src/Vitorm/Sql/SqlTranslate/QueryTranslateService.cs
  27. 1 5
      src/Vitorm/Sql/SqlTranslate/SqlTranslateArgument.cs
  28. 11 10
      src/Vitorm/Sql/SqlTranslate/SqlTranslateService.cs
  29. 1 1
      src/Vitorm/StreamQuery/SourceStream.cs
  30. 0 2
      src/Vitorm/StreamQuery/StreamReader.GroupBy.cs
  31. 0 1
      src/Vitorm/StreamQuery/StreamReader.Join.cs
  32. 0 1
      src/Vitorm/StreamQuery/StreamReader.SelectMany.cs
  33. 1 1
      src/Vitorm/StreamQuery/StreamReader.cs
  34. 12 5
      src/Vitorm/Vitorm.csproj
  35. 1 2
      test/Vitorm.Data.Console/appsettings.json
  36. 3 1
      test/Vitorm.Data.MsTest/CommonTest/ClickHouse_Test.cs
  37. 3 1
      test/Vitorm.Data.MsTest/CommonTest/MySql_Test.cs
  38. 3 1
      test/Vitorm.Data.MsTest/CommonTest/SqlServer_Test.cs
  39. 1 2
      test/Vitorm.Data.MsTest/CommonTest/Sqlite_Test.cs
  40. 1 1
      test/Vitorm.Data.MsTest/Vitorm.Data.MsTest.csproj
  41. 4 4
      test/Vitorm.Data.MsTest/appsettings.json
  42. 1 1
      test/Vitorm.MySql.MsTest/DataSource.cs
  43. 1 1
      test/Vitorm.MySql.MsTest/Vitorm.MySql.MsTest.csproj
  44. 3 3
      test/Vitorm.MySql.MsTest/appsettings.json
  45. 1 1
      test/Vitorm.SqlServer.MsTest/Vitorm.SqlServer.MsTest.csproj
  46. 3 3
      test/Vitorm.SqlServer.MsTest/appsettings.json
  47. 1 1
      test/Vitorm.Sqlite.Console/Program.cs
  48. 2 2
      test/Vitorm.Sqlite.MsTest/CommonTest/CRUD_Test.cs
  49. 2 2
      test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_Numric_Caculate_Test.cs
  50. 3 4
      test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_Numric_Test.cs
  51. 2 2
      test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_String_Caculate_Test.cs
  52. 2 3
      test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_String_Test.cs
  53. 7 4
      test/Vitorm.Sqlite.MsTest/ExpressionTreeTest/ExpressionTester.cs
  54. 1 1
      test/Vitorm.Sqlite.MsTest/Vitorm.Sqlite.MsTest.csproj

+ 14 - 0
Vitorm.sln

@@ -30,6 +30,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vitorm.Data", "src\Vitorm.D
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vitorm.Data.MsTest", "test\Vitorm.Data.MsTest\Vitorm.Data.MsTest.csproj", "{BF06299A-78A1-44C9-BCE6-4226BA326739}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vitorm.Data.Console", "test\Vitorm.Data.Console\Vitorm.Data.Console.csproj", "{DACD0587-AF7F-4ACC-9E67-1E8196C66DAF}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vitorm.Sqlite.Console", "test\Vitorm.Sqlite.Console\Vitorm.Sqlite.Console.csproj", "{FDE612FB-A590-4937-93E8-314C9DF9F39E}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -72,6 +76,14 @@ Global
 		{BF06299A-78A1-44C9-BCE6-4226BA326739}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{BF06299A-78A1-44C9-BCE6-4226BA326739}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{BF06299A-78A1-44C9-BCE6-4226BA326739}.Release|Any CPU.Build.0 = Release|Any CPU
+		{DACD0587-AF7F-4ACC-9E67-1E8196C66DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DACD0587-AF7F-4ACC-9E67-1E8196C66DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{DACD0587-AF7F-4ACC-9E67-1E8196C66DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{DACD0587-AF7F-4ACC-9E67-1E8196C66DAF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{FDE612FB-A590-4937-93E8-314C9DF9F39E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FDE612FB-A590-4937-93E8-314C9DF9F39E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FDE612FB-A590-4937-93E8-314C9DF9F39E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FDE612FB-A590-4937-93E8-314C9DF9F39E}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -86,6 +98,8 @@ Global
 		{31CE5879-959E-4882-8FBC-0D763FD73A0C} = {7904FE51-04FF-4477-8E3A-CC340389EE32}
 		{333BD5FC-1DFD-4F3C-8062-99573057C89F} = {05176905-A2A5-4015-9F04-2904506C902F}
 		{BF06299A-78A1-44C9-BCE6-4226BA326739} = {7904FE51-04FF-4477-8E3A-CC340389EE32}
+		{DACD0587-AF7F-4ACC-9E67-1E8196C66DAF} = {7904FE51-04FF-4477-8E3A-CC340389EE32}
+		{FDE612FB-A590-4937-93E8-314C9DF9F39E} = {7904FE51-04FF-4477-8E3A-CC340389EE32}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {C7DA16E3-9949-49FA-B0B4-F830636DE60F}

+ 9 - 7
src/Vitorm.Data/Data.cs

@@ -42,6 +42,8 @@ namespace Vitorm
 
 
         #region LoadDataProvider
+
+        public static IDataProvider DataProvider<Entity>() => DataProvider(typeof(Entity));
         public static IDataProvider DataProvider(Type entityType)
         {
             return providerMap.GetOrAdd(entityType, GetDataProviderFromConfig);
@@ -53,19 +55,19 @@ namespace Vitorm
                     ?? throw new NotImplementedException("can not find config for type: " + entityType.FullName);
             }
         }
-        public static IDataProvider DataProvider(string classFullName)
+        public static IDataProvider DataProvider(string @namespace)
         {
-            return providerCache.FirstOrDefault(cache => cache.Match(classFullName))?.dataProvider;
+            return providerCache.FirstOrDefault(cache => cache.@namespace == @namespace)?.dataProvider;
         }
-        public static IDataProvider DataProvider<Entity>() => DataProvider(typeof(Entity));
+
 
 
         public class DataProviderCache
         {
-            public IDataProvider dataProvider;
-            public string @namespace;
-            private string classFullNamePrefix;
-            public Dictionary<string, object> dataSourceConfig;
+            public readonly IDataProvider dataProvider;
+            public readonly string @namespace;
+            private readonly string classFullNamePrefix;
+            public readonly Dictionary<string, object> dataSourceConfig;
 
             public DataProviderCache(IDataProvider dataProvider, Dictionary<string, object> dataSourceConfig)
             {

+ 1 - 1
src/Vitorm.Data/Vitorm.Data.csproj

@@ -25,7 +25,7 @@
     </ItemGroup>
 
     <ItemGroup>
-        <PackageReference Include="Vit.Core" Version="2.1.21" />
+        <PackageReference Include="Vit.Core" Version="2.1.22" />
     </ItemGroup>
 
     <ItemGroup>

+ 1 - 1
src/Vitorm.MySql/SqlTransactionScope.cs

@@ -46,7 +46,7 @@ namespace Vitorm.MySql
         public class DbTransactionWrapSavePoint : DbTransactionWrap
         {
             public SqlTransaction sqlTran => (SqlTransaction)originalTransaction;
-            string savePointName;
+            readonly string savePointName;
             public DbTransactionWrapSavePoint(IDbTransaction transaction, string savePointName) : base(transaction)
             {
                 this.savePointName = savePointName;

+ 5 - 4
src/Vitorm.MySql/SqlTransactionScope_Command.cs

@@ -1,8 +1,9 @@
-using System.Data;
+using System.Collections.Generic;
+using System.Data;
 
 using Vitorm.Sql;
 using Vitorm.Sql.Transaction;
-using System.Collections.Generic;
+
 using static Vitorm.Sql.Transaction.DbTransactionWrap;
 
 namespace Vitorm.MySql
@@ -73,7 +74,7 @@ namespace Vitorm.MySql
         {
             public virtual System.Data.IsolationLevel IsolationLevel => default;
             public IDbConnection Connection => dbContext.dbConnection;
-            SqlDbContext dbContext;
+            readonly SqlDbContext dbContext;
             public virtual ETransactionState TransactionState { get; protected set; } = ETransactionState.Active;
 
             public DbTransactionWrap_Command(SqlDbContext dbContext)
@@ -117,7 +118,7 @@ namespace Vitorm.MySql
             public virtual System.Data.IsolationLevel IsolationLevel => default;
 
             public IDbConnection Connection => dbContext.dbConnection;
-            SqlDbContext dbContext;
+            readonly SqlDbContext dbContext;
             public virtual ETransactionState TransactionState { get; protected set; } = ETransactionState.Active;
             protected string savePointName;
 

+ 2 - 1
src/Vitorm.MySql/SqlTranslateService.cs

@@ -4,10 +4,11 @@ using System.Linq.Expressions;
 
 using Vit.Linq;
 using Vit.Linq.ExpressionTree.ComponentModel;
+
 using Vitorm.Entity;
+using Vitorm.MySql.TranslateService;
 using Vitorm.Sql;
 using Vitorm.Sql.SqlTranslate;
-using Vitorm.MySql.TranslateService;
 using Vitorm.StreamQuery;
 
 namespace Vitorm.MySql

+ 2 - 3
src/Vitorm.SqlServer/SqlTransactionScope.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Data;
+using System.Data;
 
 using Vitorm.Sql;
 using Vitorm.Sql.Transaction;
@@ -46,7 +45,7 @@ namespace Vitorm.SqlServer
     public class DbTransactionWrapSavePoint : DbTransactionWrap
     {
         public SqlTransaction sqlTran => (SqlTransaction)originalTransaction;
-        string savePointName;
+        readonly string savePointName;
         public DbTransactionWrapSavePoint(IDbTransaction transaction, string savePointName) : base(transaction)
         {
             this.savePointName = savePointName;

+ 3 - 3
src/Vitorm.SqlServer/SqlTranslate/QueryTranslateService.cs

@@ -7,7 +7,7 @@ using Vitorm.StreamQuery;
 
 namespace Vitorm.SqlServer.SqlTranslate
 {
-    public class QueryTranslateService: BaseQueryTranslateService
+    public class QueryTranslateService : BaseQueryTranslateService
     {
 
         /* // sql
@@ -36,8 +36,8 @@ ROW_NUMBER() OVER(ORDER BY @@RowCount) AS [__RowNumber__]
                 case "Count":
                     {
                         var reader = new NumScalarReader();
-                        if (arg.dataReader == null) arg.dataReader = reader;
-                        return prefix+" "+ "count(*)";
+                        arg.dataReader ??= reader;
+                        return prefix + " " + "count(*)";
                     }
                 case "" or null or "ToList" or nameof(Orm_Extensions.ToExecuteString):
                     {

+ 1 - 1
src/Vitorm.SqlServer/SqlTranslateService.cs

@@ -98,7 +98,7 @@ namespace Vitorm.SqlServer
                                     var value = methodCall.arguments[0];
                                     return $"{EvalExpression(arg, str)} like '%'+{EvalExpression(arg, value)}+'%'";
                                 }
-                            #endregion
+                                #endregion
                         }
                         break;
                     }

+ 2 - 3
src/Vitorm.Sqlite/SqlTransactionScope.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Data;
+using System.Data;
 
 using Vitorm.Sql;
 using Vitorm.Sql.Transaction;
@@ -47,7 +46,7 @@ namespace Vitorm.Sqlite
     public class DbTransactionWrapSavePoint : DbTransactionWrap
     {
         public SqlTransaction sqlTran => (SqlTransaction)originalTransaction;
-        string savePointName;
+        readonly string savePointName;
         public DbTransactionWrapSavePoint(IDbTransaction transaction, string savePointName) : base(transaction)
         {
             this.savePointName = savePointName;

+ 1 - 1
src/Vitorm.Sqlite/SqlTranslateService.cs

@@ -70,7 +70,7 @@ namespace Vitorm.Sqlite
                                     var value = methodCall.arguments[0];
                                     return $"{EvalExpression(arg, str)} like '%'||{EvalExpression(arg, value)}||'%'";
                                 }
-                            #endregion
+                                #endregion
                         }
                         break;
                     }

+ 1 - 1
src/Vitorm/DbSet.cs

@@ -20,7 +20,7 @@ namespace Vitorm
                      .Invoke(null, new object[] { dbContext, entityDescriptor }) as IDbSet;
         }
 
-        static MethodInfo _CreateDbSet = new Func<DbContext, IEntityDescriptor, IDbSet>(CreateDbSet<object>)
+        static readonly MethodInfo _CreateDbSet = new Func<DbContext, IEntityDescriptor, IDbSet>(CreateDbSet<object>)
                    .Method.GetGenericMethodDefinition();
         public static IDbSet CreateDbSet<Entity>(DbContext dbContext, IEntityDescriptor entityDescriptor)
         {

+ 1 - 1
src/Vitorm/Entity/DataAnnotations/ColumnDescriptor.cs

@@ -20,7 +20,7 @@ namespace Vitorm.Entity.DataAnnotations
             this.isIndex = isIndex;
         }
 
-        PropertyInfo propertyInfo;
+        readonly PropertyInfo propertyInfo;
         public Type type { get; private set; }
 
         /// <summary>

+ 2 - 1
src/Vitorm/Entity/Loader/DefaultEntityLoader.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
+
 using Vitorm.Entity.LoaderAttribute;
 
 namespace Vitorm.Entity.Loader
@@ -15,7 +16,7 @@ namespace Vitorm.Entity.Loader
             loaders.Add(new EntityLoaderFromAttribute());
         }
 
-        ConcurrentDictionary<Type, IEntityDescriptor> descriptorCache = new();
+        readonly ConcurrentDictionary<Type, IEntityDescriptor> descriptorCache = new();
 
         public void CleanCache()
         {

+ 1 - 0
src/Vitorm/Entity/LoaderAttribute/EntityLoaderFromAttribute.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Reflection;
+
 using Vitorm.Entity.Loader;
 
 namespace Vitorm.Entity.LoaderAttribute

+ 3 - 2
src/Vitorm/Sql/DataReader/EntityReader.cs

@@ -6,6 +6,7 @@ using System.Reflection;
 
 using Vit.Linq.ExpressionTree;
 using Vit.Linq.ExpressionTree.ComponentModel;
+
 using Vitorm.Sql.SqlTranslate;
 
 namespace Vitorm.Sql.DataReader
@@ -116,7 +117,7 @@ namespace Vitorm.Sql.DataReader
                 if (isValueType)
                 {
                     // Value arg
-                    string sqlFieldName = sqlTranslator.GetSqlField(member,arg.dbContext);
+                    string sqlFieldName = sqlTranslator.GetSqlField(member, arg.dbContext);
                     argReader = new ValueReader(this, argType, argUniqueKey, argName, sqlFieldName);
                 }
                 else
@@ -147,7 +148,7 @@ namespace Vitorm.Sql.DataReader
             }
             return argReader.argName;
         }
- 
+
 
 
     }

+ 1 - 2
src/Vitorm/Sql/DataReader/EntityReader/ModelReader.cs

@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Data;
 
-using Vit.Linq.ExpressionTree.ComponentModel;
 using Vitorm.Entity;
 using Vitorm.Sql.SqlTranslate;
 
@@ -15,7 +14,7 @@ namespace Vitorm.Sql.DataReader
         public Type argType { get; set; }
 
         //EntityPropertyReader keyPropertyReader;
-        List<EntityPropertyReader> proppertyReaders = new();
+        readonly List<EntityPropertyReader> proppertyReaders = new();
 
         public ModelReader(EntityReader entityReader, ISqlTranslateService sqlTranslator, string tableName, string argUniqueKey, string argName, Type argType, IEntityDescriptor entityDescriptor)
         {

+ 1 - 1
src/Vitorm/Sql/DataReader/EntityReader/SqlFieldReader.cs

@@ -1,6 +1,6 @@
 using System;
-using System.Data;
 using System.Collections.Generic;
+using System.Data;
 
 namespace Vitorm.Sql.DataReader
 {

+ 1 - 3
src/Vitorm/Sql/DataReader/FirstEntityReader.cs

@@ -1,13 +1,11 @@
 using System;
-using System.Collections.Generic;
 using System.Data;
 using System.Linq;
 using System.Reflection;
-using System.Text;
 
 namespace Vitorm.Sql.DataReader
 {
-    public class FirstEntityReader: EntityReader
+    public class FirstEntityReader : EntityReader
     {
         public bool nullable = true;
         public override object ReadData(IDataReader reader)

+ 1 - 1
src/Vitorm/Sql/IDbDataReader.cs

@@ -1,4 +1,4 @@
- 
+
 
 namespace Vitorm.Sql
 {

+ 1 - 2
src/Vitorm/Sql/SqlDbContext.cs

@@ -311,8 +311,7 @@ namespace Vitorm.Sql
 
             // #3.3 Query
             // #3.3.1
-            var combinedStream = stream as CombinedStream;
-            if (combinedStream == null) combinedStream = new CombinedStream("tmp") { source = stream };
+            if (stream is not CombinedStream combinedStream) combinedStream = new CombinedStream("tmp") { source = stream };
 
             // #3.3.2 execute and read result
             switch (combinedStream.method)

+ 5 - 5
src/Vitorm/Sql/SqlTranslate/BaseQueryTranslateService.cs

@@ -38,7 +38,7 @@ namespace Vitorm.Sql.SqlTranslate
             #region #2 join
             if (stream.joins != null)
             {
-                sql +=  ReadJoin(arg,stream);
+                sql += ReadJoin(arg, stream);
             }
             #endregion
 
@@ -128,9 +128,9 @@ namespace Vitorm.Sql.SqlTranslate
             {
                 throw new NotSupportedException("[QueryTranslator] groupByFields is not valid: must be New or Member");
             }
-           return String.Join(", ", fields);
+            return String.Join(", ", fields);
         }
-        protected virtual string ReadOrderBy(QueryTranslateArgument arg, CombinedStream stream) 
+        protected virtual string ReadOrderBy(QueryTranslateArgument arg, CombinedStream stream)
         {
             var fields = stream.orders.Select(field =>
                 {
@@ -148,7 +148,7 @@ namespace Vitorm.Sql.SqlTranslate
             if (stream is SourceStream sourceStream)
             {
                 IQueryable query = sourceStream.GetSource() as IQueryable;
-                var entityDescriptor = arg.dbContext.GetEntityDescriptor(query.ElementType) ;
+                var entityDescriptor = arg.dbContext.GetEntityDescriptor(query.ElementType);
                 return $"{sqlTranslator.DelimitTableName(entityDescriptor)} as " + stream.alias;
             }
             if (stream is CombinedStream baseStream)
@@ -182,7 +182,7 @@ namespace Vitorm.Sql.SqlTranslate
             //    throw new NotSupportedException("resultEntityType could not be null");
 
             var sqlFields = reader.BuildSelect(arg, resultEntityType, sqlTranslator, arg.dbContext.convertService, selectedFields);
-            if (arg.dataReader == null) arg.dataReader = reader;
+            arg.dataReader ??= reader;
             return (stream.distinct == true ? "distinct " : "") + sqlFields;
         }
 

+ 1 - 1
src/Vitorm/Sql/SqlTranslate/IQueryTranslateService.cs

@@ -2,7 +2,7 @@
 
 namespace Vitorm.Sql.SqlTranslate
 {
-    public interface IQueryTranslateService 
+    public interface IQueryTranslateService
     {
         string BuildQuery(QueryTranslateArgument arg, CombinedStream stream);
     }

+ 2 - 2
src/Vitorm/Sql/SqlTranslate/ISqlTranslateService.cs

@@ -45,7 +45,7 @@ namespace Vitorm.Sql.SqlTranslate
 
         // #2 Retrieve : PrepareGet PrepareQuery
         string PrepareGet(SqlTranslateArgument arg);
-        (string sql, Dictionary<string, object> sqlParam, IDbDataReader dataReader) PrepareQuery(QueryTranslateArgument arg,CombinedStream combinedStream);
+        (string sql, Dictionary<string, object> sqlParam, IDbDataReader dataReader) PrepareQuery(QueryTranslateArgument arg, CombinedStream combinedStream);
 
 
 
@@ -59,7 +59,7 @@ namespace Vitorm.Sql.SqlTranslate
 
         (string sql, Dictionary<string, object> sqlParam) PrepareDeleteByKeys<Key>(SqlTranslateArgument arg, IEnumerable<Key> keys);
 
-        (string sql, Dictionary<string, object> sqlParam) PrepareExecuteDelete(QueryTranslateArgument arg,CombinedStream combinedStream);
+        (string sql, Dictionary<string, object> sqlParam) PrepareExecuteDelete(QueryTranslateArgument arg, CombinedStream combinedStream);
 
 
 

+ 1 - 4
src/Vitorm/Sql/SqlTranslate/QueryTranslateArgument.cs

@@ -1,15 +1,12 @@
 using System;
 using System.Collections.Generic;
-using System.Text;
-
-using Vitorm.Entity;
 
 namespace Vitorm.Sql.SqlTranslate
 {
     public class QueryTranslateArgument
     {
         public DbContext dbContext { get; protected set; }
- 
+
         public Type resultEntityType { get; protected set; }
 
 

+ 4 - 3
src/Vitorm/Sql/SqlTranslate/QueryTranslateService.cs

@@ -1,4 +1,5 @@
 using System;
+
 using Vitorm.DataReader;
 using Vitorm.Sql.DataReader;
 using Vitorm.StreamQuery;
@@ -31,7 +32,7 @@ namespace Vitorm.Sql.SqlTranslate
                 case "Count":
                     {
                         var reader = new NumScalarReader();
-                        if (arg.dataReader == null) arg.dataReader = reader;
+                        arg.dataReader ??= reader;
                         return prefix + " " + "count(*)";
                     }
                 case "" or null or "ToList" or nameof(Orm_Extensions.ToExecuteString):
@@ -49,12 +50,12 @@ namespace Vitorm.Sql.SqlTranslate
 
                         var nullable = stream.method.Contains("OrDefault");
                         var reader = new FirstEntityReader { nullable = nullable };
-                        return prefix + " " + BuildReader(arg,stream,reader);
+                        return prefix + " " + BuildReader(arg, stream, reader);
                     }
             }
             throw new NotSupportedException("not supported method: " + stream.method);
         }
-     
+
 
 
     }

+ 1 - 5
src/Vitorm/Sql/SqlTranslate/SqlTranslateArgument.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using Vitorm.Entity;
+using Vitorm.Entity;
 
 namespace Vitorm.Sql.SqlTranslate
 {

+ 11 - 10
src/Vitorm/Sql/SqlTranslate/SqlTranslateService.cs

@@ -1,13 +1,14 @@
 using System;
+using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
 
 using Vit.Linq.ExpressionTree.ComponentModel;
+
 using Vitorm.Entity;
-using System.Linq;
 using Vitorm.StreamQuery;
-using System.Collections;
-using System.Text;
-using System.Linq.Expressions;
 
 namespace Vitorm.Sql.SqlTranslate
 {
@@ -210,7 +211,7 @@ namespace Vitorm.Sql.SqlTranslate
                                     var parameterValue = source;
 
 
-                                    Func<ExpressionNode_Member, ExpressionNode> GetParameter = (member) =>
+                                    ExpressionNode GetParameter(ExpressionNode_Member member)
                                     {
                                         if (member.nodeType == NodeType.Member && member.parameterName == parameterName)
                                         {
@@ -224,7 +225,7 @@ namespace Vitorm.Sql.SqlTranslate
                                             }
                                         }
                                         return default;
-                                    };
+                                    }
 
                                     var body = StreamReader.DeepClone(lambdaFieldSelect.body, GetParameter);
                                     var funcName = methodCall.methodName;
@@ -335,7 +336,7 @@ namespace Vitorm.Sql.SqlTranslate
             var entityDescriptor = arg.entityDescriptor;
 
             // #1 GetSqlParams 
-            Func<object, Dictionary<string, object>> GetSqlParams = (entity) =>
+            Dictionary<string, object> GetSqlParams(object entity)
             {
                 var sqlParam = new Dictionary<string, object>();
                 foreach (var column in columns)
@@ -343,7 +344,7 @@ namespace Vitorm.Sql.SqlTranslate
                     sqlParam[column.columnName] = column.GetValue(entity);
                 }
                 return sqlParam;
-            };
+            }
 
             #region #2 columns 
             List<string> columnNames = new List<string>();
@@ -398,7 +399,7 @@ namespace Vitorm.Sql.SqlTranslate
             var sqlParam = new Dictionary<string, object>();
 
             // #1 GetSqlParams
-            Func<object, Dictionary<string, object>> GetSqlParams = (entity) =>
+            Dictionary<string, object> GetSqlParams(object entity)
             {
                 var sqlParam = new Dictionary<string, object>();
                 foreach (var column in entityDescriptor.allColumns)
@@ -410,7 +411,7 @@ namespace Vitorm.Sql.SqlTranslate
                 }
                 //sqlParam[entityDescriptor.keyName] = entityDescriptor.key.Get(entity);
                 return sqlParam;
-            };
+            }
 
             // #2 columns
             List<string> columnsToUpdate = new List<string>();

+ 1 - 1
src/Vitorm/StreamQuery/SourceStream.cs

@@ -10,7 +10,7 @@ namespace Vitorm.StreamQuery
             this.alias = alias;
         }
         public string alias { get; private set; }
-        private object source;
+        private readonly object source;
 
         public int? hashCode
         {

+ 0 - 2
src/Vitorm/StreamQuery/StreamReader.GroupBy.cs

@@ -1,6 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Text;
 
 using Vit.Linq.ExpressionTree.ComponentModel;
 

+ 0 - 1
src/Vitorm/StreamQuery/StreamReader.Join.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 
 using Vit.Linq.ExpressionTree.ComponentModel;
 

+ 0 - 1
src/Vitorm/StreamQuery/StreamReader.SelectMany.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 
 using Vit.Linq.ExpressionTree.ComponentModel;
 

+ 1 - 1
src/Vitorm/StreamQuery/StreamReader.cs

@@ -437,7 +437,7 @@ namespace Vitorm.StreamQuery
             if (fields?.nodeType == NodeType.Member)
             {
                 ExpressionNode_Member member = fields;
-                if (member.parameterName == resultSelector.parameterNames[0] && member.memberName == null) 
+                if (member.parameterName == resultSelector.parameterNames[0] && member.memberName == null)
                     isDefaultSelect = true;
             }
             else if (fields?.nodeType == NodeType.New)

+ 12 - 5
src/Vitorm/Vitorm.csproj

@@ -15,18 +15,25 @@
         <Description>Vitorm : simple orm</Description>
         <PackageProjectUrl>https://github.com/VitormLib/Vitorm</PackageProjectUrl>
         <PackageIcon>vitorm_logo_v1.png</PackageIcon>
+        <PackageReadmeFile>README.md</PackageReadmeFile>
+        <RepositoryUrl>https://github.com/VitormLib/Vitorm</RepositoryUrl>
+        <PackageTags>orm</PackageTags>
     </PropertyGroup>
 
     <ItemGroup>
-      <None Include="..\..\doc\vitorm_logo_v1.png">
-        <Pack>True</Pack>
-        <PackagePath>\</PackagePath>
-      </None>
+        <None Include="..\..\doc\vitorm_logo_v1.png">
+            <Pack>True</Pack>
+            <PackagePath>\</PackagePath>
+        </None>
+        <None Include="..\..\README.md">
+            <Pack>True</Pack>
+            <PackagePath>\</PackagePath>
+        </None>
     </ItemGroup>
 
     <ItemGroup>
         <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
-        <PackageReference Include="Vit.Linq" Version="2.2.22" />
+        <PackageReference Include="Vit.Linq" Version="2.2.23" />
     </ItemGroup>
 
 </Project>

+ 1 - 2
test/Vitorm.Data.Console/appsettings.json

@@ -2,8 +2,7 @@
   "Vitorm": {
     "Data": [
       {
-        "provider": "Vitorm.Sqlite.DataProvider",
-        "assemblyFile": "Vitorm.Sqlite.dll",
+        "provider": "Sqlite",
         "namespace": "App",
         "connectionString": "data source=sqlite.db;"
       }

+ 3 - 1
test/Vitorm.Data.MsTest/CommonTest/ClickHouse_Test.cs

@@ -1,7 +1,9 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-using User = Vitorm.MsTest.ClickHouse.User;
+
 using Vitorm.Sql;
 
+using User = Vitorm.MsTest.ClickHouse.User;
+
 namespace Vitorm.MsTest.ClickHouse
 {
     public class User : Vitorm.MsTest.UserBase

+ 3 - 1
test/Vitorm.Data.MsTest/CommonTest/MySql_Test.cs

@@ -1,7 +1,9 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-using User = Vitorm.MsTest.MySql.User;
+
 using Vitorm.Sql;
 
+using User = Vitorm.MsTest.MySql.User;
+
 namespace Vitorm.MsTest.MySql
 {
     public class User : Vitorm.MsTest.UserBase

+ 3 - 1
test/Vitorm.Data.MsTest/CommonTest/SqlServer_Test.cs

@@ -1,7 +1,9 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-using User = Vitorm.MsTest.SqlServer.User;
+
 using Vitorm.Sql;
 
+using User = Vitorm.MsTest.SqlServer.User;
+
 namespace Vitorm.MsTest.SqlServer
 {
     public class User : Vitorm.MsTest.UserBase

+ 1 - 2
test/Vitorm.Data.MsTest/CommonTest/Sqlite_Test.cs

@@ -1,7 +1,6 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
+
 using User = Vitorm.MsTest.Sqlite.User;
-using Vitorm.DataProvider;
-using Vitorm.Sql;
 
 namespace Vitorm.MsTest.Sqlite
 {

+ 1 - 1
test/Vitorm.Data.MsTest/Vitorm.Data.MsTest.csproj

@@ -14,7 +14,7 @@
         <PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
         <PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
 
-        <PackageReference Include="Vit.Core" Version="2.1.21" />
+        <PackageReference Include="Vit.Core" Version="2.1.22" />
     </ItemGroup>
 
     <ItemGroup>

+ 4 - 4
test/Vitorm.Data.MsTest/appsettings.json

@@ -14,7 +14,7 @@
 
         "namespace": "Vitorm.MsTest.MySql",
         "//commandTimeout": 60,
-        "connectionString": "Data Source=ki.lith.cloud;Port=3306;Database=dev-orm;SslMode=none;User Id=root;Password=mysqlasgd234548222sdf5;CharSet=utf8;allowPublicKeyRetrieval=true;"
+        "connectionString": "Data Source=localhost;Port=3306;Database=dev-orm;SslMode=none;User Id=root;Password=123456;CharSet=utf8;allowPublicKeyRetrieval=true;"
       },
       {
         "provider": "Vitorm.SqlServer.DataProvider",
@@ -22,21 +22,21 @@
 
         "namespace": "Vitorm.MsTest.SqlServer",
         "//commandTimeout": 60,
-        "connectionString": "Server=ki.lith.cloud;Database=dev-orm;User ID=sa;Password=Admin0123;TrustServerCertificate=true;"
+        "connectionString": "Server=localhost;Database=dev-orm;User ID=sa;Password=123456;TrustServerCertificate=true;"
       },
       {
         "provider": "ClickHouse",
 
         "namespace": "Vitorm.MsTest.ClickHouse",
         "//commandTimeout": 60,
-        "connectionString": "Host=192.168.20.20;Port=8123;Database=dev-orm;User=default;Password=;Compress=True;CheckCompressedHash=False;Compressor=lz4;"
+        "connectionString": "Host=localhost;Port=8123;Database=dev-orm;User=default;Password=;Compress=True;CheckCompressedHash=False;Compressor=lz4;"
       },
       {
         "provider": "ElasticSearch",
 
         "namespace": "Vitorm.MsTest.ElasticSearch",
         "//commandTimeout": 60,
-        "connectionString": "http://ki.lith.cloud:9200"
+        "connectionString": "http://localhost:9200"
       },
 
 

+ 1 - 1
test/Vitorm.MySql.MsTest/DataSource.cs

@@ -55,7 +55,7 @@ namespace Vitorm.MsTest
     {
         public static void WaitForUpdate() { }
 
-        static string connectionString = Appsettings.json.GetStringByPath("Vitorm.MySql.connectionString");
+        static readonly string connectionString = Appsettings.json.GetStringByPath("Vitorm.MySql.connectionString");
         public static SqlDbContext CreateDbContextForWriting() => CreateDbContext();
 
         public static SqlDbContext CreateDbContext()

+ 1 - 1
test/Vitorm.MySql.MsTest/Vitorm.MySql.MsTest.csproj

@@ -14,7 +14,7 @@
         <PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
         <PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
 
-        <PackageReference Include="Vit.Core" Version="2.1.21" />
+        <PackageReference Include="Vit.Core" Version="2.1.22" />
     </ItemGroup>
 
     <ItemGroup>

+ 3 - 3
test/Vitorm.MySql.MsTest/appsettings.json

@@ -1,7 +1,7 @@
 {
-  "App": {
-    "Db": {
-      "ConnectionString": "Data Source=localhost;Port=3306;Database=dev-orm;SslMode=none;User Id=root;Password=123456;CharSet=utf8;allowPublicKeyRetrieval=true;"
+  "Vitorm": {
+    "MySql": {
+      "connectionString": "Data Source=localhost;Port=3306;Database=dev-orm;SslMode=none;User Id=root;Password=123456;CharSet=utf8;allowPublicKeyRetrieval=true;"
     }
   }
 }

+ 1 - 1
test/Vitorm.SqlServer.MsTest/Vitorm.SqlServer.MsTest.csproj

@@ -14,7 +14,7 @@
         <PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
         <PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
 
-        <PackageReference Include="Vit.Core" Version="2.1.21" />
+        <PackageReference Include="Vit.Core" Version="2.1.22" />
     </ItemGroup>
 
     <ItemGroup>

+ 3 - 3
test/Vitorm.SqlServer.MsTest/appsettings.json

@@ -1,7 +1,7 @@
 {
-  "App": {
-    "Db": {
-      "ConnectionString": "Server=localhost;Database=dev-orm;User ID=sa;Password=Admin0123;TrustServerCertificate=true;"
+  "Vitorm": {
+    "SqlServer": {
+      "connectionString": "Server=localhost;Database=dev-orm;User ID=sa;Password=123456;TrustServerCertificate=true;"
     }
   }
 }

+ 1 - 1
test/Vitorm.Sqlite.Console/Program.cs

@@ -7,7 +7,7 @@ namespace App
         static void Main(string[] args)
         {
             // #1 Create an empty SQLite database file and configures Vitorm
-            File.WriteAllBytes("sqlite.db", new byte[0]);
+            File.WriteAllBytes("sqlite.db", Array.Empty<byte>());
             using var dbContext = new Vitorm.Sql.SqlDbContext();
             dbContext.UseSqlite("data source=sqlite.db");
 

+ 2 - 2
test/Vitorm.Sqlite.MsTest/CommonTest/CRUD_Test.cs

@@ -1,6 +1,6 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Data;
 
-using System.Data;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 namespace Vitorm.MsTest.CommonTest
 {

+ 2 - 2
test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_Numric_Caculate_Test.cs

@@ -1,6 +1,6 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Data;
 
-using System.Data;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 namespace Vitorm.MsTest.CommonTest
 {

+ 3 - 4
test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_Numric_Test.cs

@@ -1,7 +1,6 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Data;
 
-using System.Data;
-using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 namespace Vitorm.MsTest.CommonTest
 {
@@ -21,7 +20,7 @@ namespace Vitorm.MsTest.CommonTest
             {
                 var userList = userQuery.Where(u => new[] { 3, 5 }.Contains(u.id)).ToList();
                 Assert.AreEqual(2, userList.Count);
-                Assert.AreEqual(0, userList.Select(m => m.id).Except(new[] { 3,5 }).Count());
+                Assert.AreEqual(0, userList.Select(m => m.id).Except(new[] { 3, 5 }).Count());
             }
 
             // Enumerable.Contains

+ 2 - 2
test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_String_Caculate_Test.cs

@@ -1,6 +1,6 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Data;
 
-using System.Data;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 namespace Vitorm.MsTest.CommonTest
 {

+ 2 - 3
test/Vitorm.Sqlite.MsTest/CommonTest/Query_Type_String_Test.cs

@@ -1,7 +1,6 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Data;
 
-using System.Data;
-using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 namespace Vitorm.MsTest.CommonTest
 {

+ 7 - 4
test/Vitorm.Sqlite.MsTest/ExpressionTreeTest/ExpressionTester.cs

@@ -1,7 +1,9 @@
-using System.Linq.Expressions;
-using Vit.Linq;
+using System.Data;
+using System.Linq.Expressions;
+
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Data;
+
+using Vit.Linq;
 
 namespace Vit.Linq.ExpressionTree.ExpressionTreeTest
 {
@@ -12,13 +14,14 @@ namespace Vit.Linq.ExpressionTree.ExpressionTreeTest
         public static List<User> Test(IQueryable<User> query, Expression<Func<User, bool>> predicate)
         {
             var expected = GetSourceData().AsQueryable().Where(predicate).ToList();
+
             {
                 var actual = query.Where(predicate).ToList();
                 Check(expected, actual);
                 return actual;
             }
 
-            void Check(List<User> expected, List<User> actual)
+            static void Check(List<User> expected, List<User> actual)
             {
                 Assert.AreEqual(expected.Count, actual.Count);
                 for (var t = 0; t < expected.Count; t++)

+ 1 - 1
test/Vitorm.Sqlite.MsTest/Vitorm.Sqlite.MsTest.csproj

@@ -14,7 +14,7 @@
         <PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
         <PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
 
-        <PackageReference Include="Vit.Core" Version="2.1.21" />
+        <PackageReference Include="Vit.Core" Version="2.1.22" />
     </ItemGroup>
 
     <ItemGroup>