Lith 10 mēneši atpakaļ
vecāks
revīzija
b490430d2a

+ 130 - 23
README.md

@@ -28,6 +28,58 @@ This means you get the best of both worlds: the performance and simplicity of Da
 
 
 
+# Comparison of performance with other ORMs
+> Through benchmarks, there may be slight variations depending on the database source, for reference only.
+
+## SqlServer 
+| Method | queryJoin | take | runner                 | Mean         | Error     | StdDev    |
+|------- |---------- |----- |----------------------- |-------------:|----------:|----------:|
+| Run    | False     | 1    | Runner_EntityFramework |     5.380 ms | 0.0449 ms | 0.0398 ms |
+| Run    | False     | 1    | Runner_SqlSuger        |     4.929 ms | 0.0588 ms | 0.0550 ms |
+| Run    | False     | 1    | Runner_Vitorm          |     4.925 ms | 0.0506 ms | 0.0474 ms |
+| Run    | False     | 1000 | Runner_EntityFramework |     6.009 ms | 0.0963 ms | 0.0853 ms |
+| Run    | False     | 1000 | Runner_SqlSuger        |     5.616 ms | 0.1114 ms | 0.1488 ms |
+| Run    | False     | 1000 | Runner_Vitorm          |     5.539 ms | 0.1060 ms | 0.1262 ms |
+| Run    | True      | 1    | Runner_EntityFramework |     5.453 ms | 0.0571 ms | 0.0534 ms |
+| Run    | True      | 1    | Runner_SqlSuger        |     5.601 ms | 0.0477 ms | 0.0423 ms |
+| Run    | True      | 1    | Runner_Vitorm          |     5.337 ms | 0.0596 ms | 0.0528 ms |
+| Run    | True      | 1000 | Runner_EntityFramework | 1,706.222 ms | 4.4435 ms | 3.9391 ms |
+| Run    | True      | 1000 | Runner_SqlSuger        |   125.150 ms | 2.3678 ms | 2.3255 ms |
+| Run    | True      | 1000 | Runner_Vitorm          |    21.027 ms | 0.3564 ms | 0.3334 ms |
+
+## MySql 
+| Method | queryJoin | take | runner                 | Mean         | Error       | StdDev      |
+|------- |---------- |----- |----------------------- |-------------:|------------:|------------:|
+| Run    | False     | 1    | Runner_EntityFramework |   1,231.1 μs |    47.43 μs |   139.84 μs |
+| Run    | False     | 1    | Runner_SqlSuger        |     873.7 μs |    22.33 μs |    65.49 μs |
+| Run    | False     | 1    | Runner_Vitorm          |     636.7 μs |    21.15 μs |    62.37 μs |
+| Run    | False     | 1000 | Runner_EntityFramework |   4,764.8 μs |    56.52 μs |    52.87 μs |
+| Run    | False     | 1000 | Runner_SqlSuger        |   1,906.4 μs |    33.21 μs |    42.00 μs |
+| Run    | False     | 1000 | Runner_Vitorm          |   2,159.5 μs |    43.16 μs |    56.12 μs |
+| Run    | True      | 1    | Runner_EntityFramework |   1,775.0 μs |    35.01 μs |    80.45 μs |
+| Run    | True      | 1    | Runner_SqlSuger        |   1,747.5 μs |    34.05 μs |    44.27 μs |
+| Run    | True      | 1    | Runner_Vitorm          |   1,292.5 μs |    25.72 μs |    41.54 μs |
+| Run    | True      | 1000 | Runner_EntityFramework |   6,784.4 μs |   102.05 μs |    95.45 μs |
+| Run    | True      | 1000 | Runner_SqlSuger        | 113,634.4 μs | 1,128.58 μs | 1,055.67 μs |
+| Run    | True      | 1000 | Runner_Vitorm          |   3,175.2 μs |    62.02 μs |    88.95 μs |
+
+## Sqlite
+| Method | queryJoin | take | runner                 | Mean          | Error      | StdDev     |
+|------- |---------- |----- |----------------------- |--------------:|-----------:|-----------:|
+| Run    | False     | 1    | Runner_EntityFramework |     115.32 μs |   0.831 μs |   0.778 μs |
+| Run    | False     | 1    | Runner_SqlSuger        |      81.66 μs |   0.747 μs |   0.699 μs |
+| Run    | False     | 1    | Runner_Vitorm          |      45.64 μs |   0.350 μs |   0.328 μs |
+| Run    | False     | 1000 | Runner_EntityFramework |   1,386.81 μs |  13.684 μs |  12.800 μs |
+| Run    | False     | 1000 | Runner_SqlSuger        |     674.82 μs |   4.938 μs |   4.619 μs |
+| Run    | False     | 1000 | Runner_Vitorm          |     769.88 μs |   6.020 μs |   5.631 μs |
+| Run    | True      | 1    | Runner_EntityFramework |     220.27 μs |   1.916 μs |   1.793 μs |
+| Run    | True      | 1    | Runner_SqlSuger        |     484.52 μs |   6.746 μs |   5.980 μs |
+| Run    | True      | 1    | Runner_Vitorm          |     167.89 μs |   1.352 μs |   1.264 μs |
+| Run    | True      | 1000 | Runner_EntityFramework |   1,962.25 μs |  10.031 μs |   8.377 μs |
+| Run    | True      | 1000 | Runner_SqlSuger        | 103,179.50 μs | 534.265 μs | 446.135 μs |
+| Run    | True      | 1000 | Runner_Vitorm          |   1,684.39 μs |  21.895 μs |  18.283 μs |
+
+
 
 # Vitorm Documentation
 This guide will walk you through the steps to set up and use Vitorm with SQLite.
@@ -36,8 +88,8 @@ supported features:
 
 | feature    |  method   |  remarks   |     |
 | --- | --- | --- | --- |
-|  create table   |  Create   |     |     |
-|  drop table   |  Drop   |     |     |
+|  create table   |  TryCreateTable   |     |     |
+|  drop table   |  TryDropTable   |     |     |
 | --- | --- | --- | --- |
 |  create records   |  Add AddRange   |     |     |
 |  retrieve  records |  Query Get   |     |     |
@@ -53,32 +105,62 @@ supported features:
 
 
 ## Installation
-Before using Vitorm, install the necessary package:
-
+Before using Vitorm, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.Sqlite
 ```
 
-## Using Vitorm
-> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
+## Minimum viable demo
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            // #1 Init
+            using var dbContext = new Vitorm.Sql.SqlDbContext();
+            dbContext.UseSqlite("data source=sqlite.db");
+
+            // #2 Query
+            var user = dbContext.Get<User>(1);
+            var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+```
 
+
+## Full Example
+> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
 ``` csharp
-using Vit.Extensions.Vitorm_Extensions;
 using Vitorm;
 
 namespace App
 {
-    public class Program
+    public class Program_Min
     {
         static void Main(string[] args)
         {
-            // #1 Configure Vitorm
+            // #1 Configures Vitorm
             using var dbContext = new Vitorm.Sql.SqlDbContext();
             dbContext.UseSqlite("data source=sqlite.db");
 
             // #2 Create Table
-            dbContext.Drop<User>();
-            dbContext.Create<User>();
+            dbContext.TryDropTable<User>();
+            dbContext.TryCreateTable<User>();
 
             // #3 Insert Records
             dbContext.Add(new User { id = 1, name = "lith" });
@@ -176,9 +258,8 @@ namespace App
 }
 ```
 
-## Explanation
-
-1. **Setup**: Initializes the SQLite database and configures Vitorm.
+## Explanation   
+1. **Setup**: Initializes the database and configures Vitorm.
 2. **Create Table**: Drops and recreates the `User` table.
 3. **Insert Records**: Adds single and multiple user records.
 4. **Query Records**: Retrieves user records using various querying methods.
@@ -190,12 +271,11 @@ namespace App
 
 
 
-# Vitorm.Data Documentation
-Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.
+# Vitorm.Data Documentation    
+Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.    
  
-## Installation
-
-Before using Vitorm.Data, install the necessary package:
+## Installation    
+Before using Vitorm.Data, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.Data
 dotnet add package Vitorm.Sqlite
@@ -217,11 +297,38 @@ dotnet add package Vitorm.Sqlite
 }
 ```
 
+## Minimum viable demo
+> After configuring the `appsettings.json` file, you can directly perform queries without any additional configuration or initialization, `Vitorm.Data` is that easy to use.    
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            //  Query Records
+            var user = Data.Get<User>(1);
+            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
 
-## Using Vitorm.Data
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+
+```
 
+## Full Example    
 ``` csharp
-using Vit.Extensions.Vitorm_Extensions;
 using Vitorm;
 
 namespace App
@@ -233,8 +340,8 @@ namespace App
             // #1 No need to init Vitorm.Data
 
             // #2 Create Table
-            Data.Drop<User>();
-            Data.Create<User>();
+            Data.TryDropTable<User>();
+            Data.TryCreateTable<User>();
 
             // #3 Insert Records
             Data.Add(new User { id = 1, name = "lith" });

+ 37 - 7
src/Vitorm.Data/README.md

@@ -18,11 +18,10 @@ This means you get the best of both worlds: the performance and simplicity of Da
 
 
 
-# Vitorm.Data Documentation
-Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.
+# Vitorm.Data Documentation    
+Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.    
  
-## Installation
-
+## Installation    
 Before using Vitorm.Data, install the necessary package:
 ``` bash
 dotnet add package Vitorm.Data
@@ -45,11 +44,42 @@ dotnet add package Vitorm.Sqlite
 }
 ```
 
+## Minimum viable demo
+> After configuring the `appsettings.json` file, you can directly perform queries without any additional configuration or initialization, `Vitorm.Data` is that easy to use.    
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            //  Query Records
+            var user = Data.Get<User>(1);
+            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+
+```
+
 
 ## Using Vitorm.Data
 
 ``` csharp
-using Vit.Extensions.Vitorm_Extensions;
+
+``` csharp
 using Vitorm;
 
 namespace App
@@ -61,8 +91,8 @@ namespace App
             // #1 No need to init Vitorm.Data
 
             // #2 Create Table
-            Data.Drop<User>();
-            Data.Create<User>();
+            Data.TryDropTable<User>();
+            Data.TryCreateTable<User>();
 
             // #3 Insert Records
             Data.Add(new User { id = 1, name = "lith" });

+ 97 - 36
src/Vitorm.MySql/README.md

@@ -20,32 +20,83 @@ This means you get the best of both worlds: the performance and simplicity of Da
 # Vitorm.MySql Documentation
 This guide will walk you through the steps to set up and use Vitorm.MySql.
 
-## Installation
-Before using Vitorm.MySql, install the necessary package:
+supported features:
+
+| feature    |  method   |  remarks   |     |
+| --- | --- | --- | --- |
+|  create table   |  TryCreateTable   |     |     |
+|  drop table   |  TryDropTable   |     |     |
+| --- | --- | --- | --- |
+|  create records   |  Add AddRange   |     |     |
+|  retrieve  records |  Query Get   |     |     |
+|  update records   |  Update UpdateRange ExecuteUpdate  |     |     |
+|  delete records   |  Delete DeleteRange DeleteByKey DeleteByKeys ExecuteDelete   |     |     |
+| --- | --- | --- | --- |
+|  change table   |  ChangeTable    |  change mapping table from database   |   |
+|  change database  |  ChangeDatabase   | change database to be connected  |   |
+| --- | --- | --- | --- |
+|  collection total count   |  TotalCount    |  Collection Total Count without Take and Skip   |   |
+|  collection total count and list  |  ToListAndTotalCount   | query List and TotalCount at on request  |   |
+|     |     |   |   |
+
 
+## Installation
+Before using Vitorm, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.MySql
 ```
 
-## Using Vitorm.MySql
-> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
+## Minimum viable demo
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            // #1 Init
+            using var dbContext = new Vitorm.Sql.SqlDbContext();
+            dbContext.UseMySql("Data Source=localhost;Port=3306;Database=dev-orm;SslMode=none;User Id=root;Password=123456;CharSet=utf8;allowPublicKeyRetrieval=true;");
+
+            // #2 Query
+            var user = dbContext.Get<User>(1);
+            var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+```
 
+
+## Full Example
+> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
 ``` csharp
 using Vitorm;
 
 namespace App
 {
-    public class Program
+    public class Program_Min
     {
         static void Main(string[] args)
         {
-            // #1 Create an empty SQLite database file and configures Vitorm
+            // #1 Configures Vitorm
             using var dbContext = new Vitorm.Sql.SqlDbContext();
             dbContext.UseMySql("Data Source=localhost;Port=3306;Database=dev-orm;SslMode=none;User Id=root;Password=123456;CharSet=utf8;allowPublicKeyRetrieval=true;");
 
             // #2 Create Table
-            dbContext.Drop<User>();
-            dbContext.Create<User>();
+            dbContext.TryDropTable<User>();
+            dbContext.TryCreateTable<User>();
 
             // #3 Insert Records
             dbContext.Add(new User { id = 1, name = "lith" });
@@ -119,14 +170,6 @@ namespace App
 
                 tran1.Commit();
             }
-
-            // #9 Database Functions
-            {
-                // select * from User where IIF(t0.fatherId is not null, true, false);
-                var query = dbContext.Query<User>().Where(u => DbFunction.Call<bool>("IIF", u.fatherId != null, true, false));
-                var sql = query.ToExecuteString();
-                var userList = query.ToList();
-            }
         }
 
         // Entity Definition
@@ -143,9 +186,8 @@ namespace App
 }
 ```
 
-## Explanation
-
-1. **Setup**: Initializes the SQLite database and configures Vitorm.
+## Explanation   
+1. **Setup**: Initializes the database and configures Vitorm.
 2. **Create Table**: Drops and recreates the `User` table.
 3. **Insert Records**: Adds single and multiple user records.
 4. **Query Records**: Retrieves user records using various querying methods.
@@ -157,12 +199,11 @@ namespace App
 
 
 
-# Vitorm.Data Documentation
-Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.
+# Vitorm.Data Documentation    
+Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.    
  
-## Installation
-
-Before using Vitorm.Data, install the necessary package:
+## Installation    
+Before using Vitorm.Data, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.Data
 dotnet add package Vitorm.MySql
@@ -184,9 +225,37 @@ dotnet add package Vitorm.MySql
 }
 ```
 
+## Minimum viable demo
+> After configuring the `appsettings.json` file, you can directly perform queries without any additional configuration or initialization, `Vitorm.Data` is that easy to use.    
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            //  Query Records
+            var user = Data.Get<User>(1);
+            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
 
-## Using Vitorm.Data
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+
+```
 
+## Full Example    
 ``` csharp
 using Vitorm;
 
@@ -196,11 +265,11 @@ namespace App
     {
         static void Main(string[] args)
         {
-            // #1
+            // #1 No need to init Vitorm.Data
 
             // #2 Create Table
-            Data.Drop<User>();
-            Data.Create<User>();
+            Data.TryDropTable<User>();
+            Data.TryCreateTable<User>();
 
             // #3 Insert Records
             Data.Add(new User { id = 1, name = "lith" });
@@ -276,14 +345,6 @@ namespace App
 
                 tran1.Commit();
             }
-
-            // #9 Database Functions
-            {
-                // select * from User where IIF(t0.fatherId is not null, true, false);
-                var query = Data.Query<User>().Where(u => DbFunction.Call<bool>("IIF", u.fatherId != null, true, false));
-                var sql = query.ToExecuteString();
-                var userList = query.ToList();
-            }
         }
 
         // Entity Definition

+ 99 - 38
src/Vitorm.SqlServer/README.md

@@ -17,35 +17,86 @@ This means you get the best of both worlds: the performance and simplicity of Da
 
 
 
-# Vitorm.SqlServer Documentation
+# Vitorm Documentation
 This guide will walk you through the steps to set up and use Vitorm.SqlServer.
 
-## Installation
-Before using Vitorm.SqlServer, install the necessary package:
+supported features:
+
+| feature    |  method   |  remarks   |     |
+| --- | --- | --- | --- |
+|  create table   |  TryCreateTable   |     |     |
+|  drop table   |  TryDropTable   |     |     |
+| --- | --- | --- | --- |
+|  create records   |  Add AddRange   |     |     |
+|  retrieve  records |  Query Get   |     |     |
+|  update records   |  Update UpdateRange ExecuteUpdate  |     |     |
+|  delete records   |  Delete DeleteRange DeleteByKey DeleteByKeys ExecuteDelete   |     |     |
+| --- | --- | --- | --- |
+|  change table   |  ChangeTable    |  change mapping table from database   |   |
+|  change database  |  ChangeDatabase   | change database to be connected  |   |
+| --- | --- | --- | --- |
+|  collection total count   |  TotalCount    |  Collection Total Count without Take and Skip   |   |
+|  collection total count and list  |  ToListAndTotalCount   | query List and TotalCount at on request  |   |
+|     |     |   |   |
+
 
+## Installation
+Before using Vitorm.SqlServer, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.SqlServer
 ```
 
-## Using Vitorm.SqlServer
-> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
+## Minimum viable demo
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            // #1 Init
+            using var dbContext = new Vitorm.Sql.SqlDbContext();
+            dbContext.UseSqlServer("Server=localhost;Database=dev-orm;User ID=sa;Password=Admin0123;TrustServerCertificate=true;");
+
+            // #2 Query
+            var user = dbContext.Get<User>(1);
+            var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
 
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+```
+
+
+## Full Example
+> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
 ``` csharp
 using Vitorm;
 
 namespace App
 {
-    public class Program
+    public class Program_Min
     {
         static void Main(string[] args)
         {
-            // #1 Create an empty SQLite database file and configures Vitorm
+            // #1 Configures Vitorm
             using var dbContext = new Vitorm.Sql.SqlDbContext();
-            dbContext.UseMySql("Server=localhost;Database=dev-orm;User ID=sa;Password=123456;TrustServerCertificate=true;");
+            dbContext.UseSqlServer("Server=localhost;Database=dev-orm;User ID=sa;Password=123456;TrustServerCertificate=true;");
 
             // #2 Create Table
-            dbContext.Drop<User>();
-            dbContext.Create<User>();
+            dbContext.TryDropTable<User>();
+            dbContext.TryCreateTable<User>();
 
             // #3 Insert Records
             dbContext.Add(new User { id = 1, name = "lith" });
@@ -119,14 +170,6 @@ namespace App
 
                 tran1.Commit();
             }
-
-            // #9 Database Functions
-            {
-                // select * from User where IIF(t0.fatherId is not null, true, false);
-                var query = dbContext.Query<User>().Where(u => DbFunction.Call<bool>("IIF", u.fatherId != null, true, false));
-                var sql = query.ToExecuteString();
-                var userList = query.ToList();
-            }
         }
 
         // Entity Definition
@@ -143,9 +186,8 @@ namespace App
 }
 ```
 
-## Explanation
-
-1. **Setup**: Initializes the SQLite database and configures Vitorm.
+## Explanation   
+1. **Setup**: Initializes the database and configures Vitorm.
 2. **Create Table**: Drops and recreates the `User` table.
 3. **Insert Records**: Adds single and multiple user records.
 4. **Query Records**: Retrieves user records using various querying methods.
@@ -157,12 +199,11 @@ namespace App
 
 
 
-# Vitorm.Data Documentation
-Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.
+# Vitorm.Data Documentation    
+Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.    
  
-## Installation
-
-Before using Vitorm.Data, install the necessary package:
+## Installation    
+Before using Vitorm.Data, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.Data
 dotnet add package Vitorm.SqlServer
@@ -184,9 +225,37 @@ dotnet add package Vitorm.SqlServer
 }
 ```
 
+## Minimum viable demo
+> After configuring the `appsettings.json` file, you can directly perform queries without any additional configuration or initialization, `Vitorm.Data` is that easy to use.    
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            //  Query Records
+            var user = Data.Get<User>(1);
+            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
 
-## Using Vitorm.Data
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+
+```
 
+## Full Example    
 ``` csharp
 using Vitorm;
 
@@ -196,11 +265,11 @@ namespace App
     {
         static void Main(string[] args)
         {
-            // #1
+            // #1 No need to init Vitorm.Data
 
             // #2 Create Table
-            Data.Drop<User>();
-            Data.Create<User>();
+            Data.TryDropTable<User>();
+            Data.TryCreateTable<User>();
 
             // #3 Insert Records
             Data.Add(new User { id = 1, name = "lith" });
@@ -276,14 +345,6 @@ namespace App
 
                 tran1.Commit();
             }
-
-            // #9 Database Functions
-            {
-                // select * from User where IIF(t0.fatherId is not null, true, false);
-                var query = Data.Query<User>().Where(u => DbFunction.Call<bool>("IIF", u.fatherId != null, true, false));
-                var sql = query.ToExecuteString();
-                var userList = query.ToList();
-            }
         }
 
         // Entity Definition

+ 97 - 21
src/Vitorm.Sqlite/README.md

@@ -17,35 +17,86 @@ This means you get the best of both worlds: the performance and simplicity of Da
 
 
 
-# Vitorm.Sqlite Documentation
-This guide will walk you through the steps to set up and use Vitorm.Sqlite.
+# Vitorm Documentation
+This guide will walk you through the steps to set up and use Vitorm with SQLite.
+
+supported features:
+
+| feature    |  method   |  remarks   |     |
+| --- | --- | --- | --- |
+|  create table   |  TryCreateTable   |     |     |
+|  drop table   |  TryDropTable   |     |     |
+| --- | --- | --- | --- |
+|  create records   |  Add AddRange   |     |     |
+|  retrieve  records |  Query Get   |     |     |
+|  update records   |  Update UpdateRange ExecuteUpdate  |     |     |
+|  delete records   |  Delete DeleteRange DeleteByKey DeleteByKeys ExecuteDelete   |     |     |
+| --- | --- | --- | --- |
+|  change table   |  ChangeTable    |  change mapping table from database   |   |
+|  change database  |  ChangeDatabase   | change database to be connected  |   |
+| --- | --- | --- | --- |
+|  collection total count   |  TotalCount    |  Collection Total Count without Take and Skip   |   |
+|  collection total count and list  |  ToListAndTotalCount   | query List and TotalCount at on request  |   |
+|     |     |   |   |
 
-## Installation
-Before using Vitorm.Sqlite, install the necessary package:
 
+## Installation
+Before using Vitorm, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.Sqlite
 ```
 
-## Using Vitorm.Sqlite
-> This example provides a comprehensive guide to utilizing Vitorm.Sqlite for basic and advanced database operations while maintaining lightweight performance.    
+## Minimum viable demo
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            // #1 Init
+            using var dbContext = new Vitorm.Sql.SqlDbContext();
+            dbContext.UseSqlite("data source=sqlite.db");
+
+            // #2 Query
+            var user = dbContext.Get<User>(1);
+            var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
+```
+
 
+## Full Example
+> This example provides a comprehensive guide to utilizing Vitorm for basic and advanced database operations while maintaining lightweight performance.    
 ``` csharp
 using Vitorm;
 
 namespace App
 {
-    public class Program
+    public class Program_Min
     {
         static void Main(string[] args)
         {
-            // #1 Configure Vitorm
+            // #1 Configures Vitorm
             using var dbContext = new Vitorm.Sql.SqlDbContext();
             dbContext.UseSqlite("data source=sqlite.db");
 
             // #2 Create Table
-            dbContext.Drop<User>();
-            dbContext.Create<User>();
+            dbContext.TryDropTable<User>();
+            dbContext.TryCreateTable<User>();
 
             // #3 Insert Records
             dbContext.Add(new User { id = 1, name = "lith" });
@@ -143,8 +194,7 @@ namespace App
 }
 ```
 
-## Explanation
-
+## Explanation   
 1. **Setup**: Initializes the SQLite database and configures Vitorm.
 2. **Create Table**: Drops and recreates the `User` table.
 3. **Insert Records**: Adds single and multiple user records.
@@ -157,12 +207,11 @@ namespace App
 
 
 
-# Vitorm.Data Documentation
-Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.
+# Vitorm.Data Documentation    
+Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.    
  
-## Installation
-
-Before using Vitorm.Data, install the necessary package:
+## Installation    
+Before using Vitorm.Data, install the necessary package:    
 ``` bash
 dotnet add package Vitorm.Data
 dotnet add package Vitorm.Sqlite
@@ -184,11 +233,38 @@ dotnet add package Vitorm.Sqlite
 }
 ```
 
+## Minimum viable demo
+> After configuring the `appsettings.json` file, you can directly perform queries without any additional configuration or initialization, `Vitorm.Data` is that easy to use.    
+``` csharp
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            //  Query Records
+            var user = Data.Get<User>(1);
+            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}
 
-## Using Vitorm.Data
+```
 
+## Full Example    
 ``` csharp
-using Vit.Extensions.Vitorm_Extensions;
 using Vitorm;
 
 namespace App
@@ -200,8 +276,8 @@ namespace App
             // #1 No need to init Vitorm.Data
 
             // #2 Create Table
-            Data.Drop<User>();
-            Data.Create<User>();
+            Data.TryDropTable<User>();
+            Data.TryCreateTable<User>();
 
             // #3 Insert Records
             Data.Add(new User { id = 1, name = "lith" });

+ 10 - 9
test/Vitorm.Data.Benchmark/OrmRunner/BenchmarkRunner.cs

@@ -13,29 +13,30 @@ namespace App.OrmRunner
     }
 
     [Config(typeof(Config))]
-    //[Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.FastestToSlowest)]
+    [Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.Method)]
     [InProcess]
     public class BenchmarkRunner
     {
 
-        //[Params(100)]
-        public int N = 100;
+        //[Params(1, 100)]
+        public int N = 1;
 
         //[Params(true, false)]
         public bool executeQuery = true;
 
         [Params(false, true)]
-        public bool queryJoin = false;
+        public bool queryJoin = true;
 
 
-        [Params(10, 100, 1000)]
-        public int take = 100;
+        [Params(1, 1000)]
+        //[Params(100)]
+        public int take = 1;
 
-        [Params(0, 10)]
-        public int? skip = 10;
+        //[Params(0, 10)]
+        public int? skip = null;
 
 
-        [Params(typeof(Runner_Vitorm), typeof(Runner_EntityFramework))]
+        [Params(typeof(Runner_Vitorm), typeof(Runner_EntityFramework), typeof(Runner_SqlSuger))]
         public Type runner;
 
 

+ 55 - 74
test/Vitorm.Data.Benchmark/OrmRunner/Runner_EntityFramework.cs

@@ -1,96 +1,106 @@
-using Microsoft.EntityFrameworkCore;
+using App.OrmRunner.EntityFrameworkRunner;
 
-using Vit.Core.Util.ConfigurationManager;
-
-using Vitorm;
+using Microsoft.EntityFrameworkCore;
 
+using Vit.Core.Util.ConfigurationManager;
 
 namespace App.OrmRunner
 {
     public partial class Runner_EntityFramework : IRunner
     {
-        RunConfig config;
-
-        int? skip => config.skip;
-        int take => config.take;
-        bool executeQuery => config.executeQuery;
-
-
-
-        IQueryable<User> userQuery;
-        public IQueryable<User> GetQueryable() => userQuery;
-
-
         public void Run(RunConfig config)
         {
-            this.config = config;
-
             for (int i = 0; i < config.repeatCount; i++)
             {
                 using MyDbContext myDbContext = new MyDbContext();
-                userQuery = myDbContext.users;
+                var userQuery = myDbContext.users;
 
-                if (config.queryJoin) QueryJoin();
-                else Query();
+                if (config.queryJoin)
+                    QueryExecute.QueryJoin(userQuery, config);
+                else
+                    QueryExecute.Query(userQuery, config);
             }
         }
+    }
+}
+
+namespace App.OrmRunner.EntityFrameworkRunner
+{
+    // Entity Definition
+    [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+    public class User
+    {
+        [System.ComponentModel.DataAnnotations.Key]
+        public int id { get; set; }
+        public string name { get; set; }
+        public DateTime? birth { get; set; }
+        public int? fatherId { get; set; }
+        public int? motherId { get; set; }
+    }
+    public class MyDbContext : Microsoft.EntityFrameworkCore.DbContext
+    {
+        public Microsoft.EntityFrameworkCore.DbSet<User> users { get; set; }
 
-        #region Executor
-        int exceptUserId = 1;
-        public void QueryJoin()
+        static string provider = Appsettings.json.GetStringByPath("Vitorm.Data[0].provider");
+        static string connectionString = Appsettings.json.GetStringByPath("Vitorm.Data[0].connectionString");
+        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
         {
-            var userSet = GetQueryable();
+            switch (provider)
+            {
+                case "MySql": optionsBuilder.UseMySQL(connectionString); break;
+                case "SqlServer": optionsBuilder.UseSqlServer(connectionString); break;
+                case "Sqlite": optionsBuilder.UseSqlite(connectionString); break;
+            }
+        }
+    }
 
-            var minId = 1;
-            var config = new { maxId = 10000 };
-            var offsetId = 100;
 
+    public class QueryExecute
+    {
+
+        public static void QueryJoin(IQueryable<User> userSet, RunConfig config)
+        {
             var query =
                     from user in userSet
                     from father in userSet.Where(father => user.fatherId == father.id).DefaultIfEmpty()
                     from mother in userSet.Where(mother => user.motherId == mother.id).DefaultIfEmpty()
-                    where user.id > minId && user.id < config.maxId && user.id != exceptUserId
+                    where user.id > 1 && user.id < 10000
                     orderby user.id
                     select new
                     {
                         user,
                         father,
                         mother,
-                        testId = user.id + offsetId,
+                        testId = user.id + 100,
                         hasFather = father.name != null ? true : false
                     }
                     ;
 
-            Execute(query);
+            Execute(query, config);
         }
 
-        public void Query()
+        public static void Query(IQueryable<User> userSet, RunConfig config)
         {
-            var userSet = GetQueryable();
-
-            var minId = 1;
-            var config = new { maxId = 10000 };
-
             var query =
                     from user in userSet
-                    where user.id > minId && user.id < config.maxId && user.id != exceptUserId
+                    where user.id > 1 && user.id < 10000
                     orderby user.id
                     select user;
 
-            Execute(query);
+            Execute(query, config);
         }
-        #endregion
 
-        public void Execute<Result>(IQueryable<Result> query)
+
+        public static void Execute<Result>(IQueryable<Result> query, RunConfig config)
         {
-            if (skip > 0) query = query.Skip(skip.Value);
-            query = query.Take(take);
+            if (config.skip > 0) query = query.Skip(config.skip.Value);
+            query = query.Take(config.take);
 
-            if (executeQuery)
+            if (config.executeQuery)
             {
                 var userList = query.ToList();
                 var rowCount = userList.Count;
-                if (rowCount != take) throw new Exception($"query failed, expected row count : {take} , actual count: {rowCount} ");
+                if (rowCount != config.take) throw new Exception($"query failed, expected row count : {config.take} , actual count: {rowCount} ");
             }
             else
             {
@@ -99,34 +109,5 @@ namespace App.OrmRunner
             }
         }
 
-
-        public class MyDbContext : Microsoft.EntityFrameworkCore.DbContext
-        {
-            public Microsoft.EntityFrameworkCore.DbSet<User> users { get; set; }
-
-            static string connectionString = Appsettings.json.GetStringByPath("Vitorm.Data[0].connectionString");
-            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
-            {
-                optionsBuilder.UseSqlite(connectionString);
-            }
-        }
-
-
-
-
-
-        // Entity Definition
-        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
-        public class User
-        {
-            [System.ComponentModel.DataAnnotations.Key]
-            public int id { get; set; }
-            public string name { get; set; }
-            public DateTime? birth { get; set; }
-            public int? fatherId { get; set; }
-            public int? motherId { get; set; }
-        }
-
-
     }
 }

+ 48 - 86
test/Vitorm.Data.Benchmark/OrmRunner/Runner_SqlSugar.cs

@@ -1,34 +1,23 @@
-using SqlSugar;
+using App.OrmRunner.SqlSugerRunner;
 
-using Vit.Core.Util.ConfigurationManager;
+using SqlSugar;
 
+using Vit.Core.Util.ConfigurationManager;
 
 namespace App.OrmRunner
 {
-    public class Runner_SqlSuger : IRunner
+    public partial class Runner_SqlSuger : IRunner
     {
-        RunConfig config;
-
-        int? skip => config.skip;
-        int? take => config.take;
-        bool executeQuery => config.executeQuery;
-
-
+        static string provider = Appsettings.json.GetStringByPath("Vitorm.Data[0].provider");
         static string connectionString = Appsettings.json.GetStringByPath("Vitorm.Data[0].connectionString");
-
-
-        SqlSugarClient db;
-        public string sql;
         public void Run(RunConfig config)
         {
-            this.config = config;
-
 
             for (int i = 0; i < config.repeatCount; i++)
             {
 
                 Action<SqlSugarClient> configAction;
-                if (executeQuery)
+                if (config.executeQuery)
                 {
                     configAction = db => { };
                 }
@@ -38,14 +27,12 @@ namespace App.OrmRunner
                     {
                         db.Aop.OnLogExecuting = (sql, pars) =>
                         {
-                            //Console.WriteLine(sql); //输出sql,查看执行sql 性能无影响
+                            //Console.WriteLine(sql);
 
-                            //获取原生SQL推荐 5.1.4.63  性能OK
                             var nativeSql = UtilMethods.GetNativeSql(sql, pars);
                             //Console.WriteLine(nativeSql);
                             sql = nativeSql;
 
-                            //获取无参数化SQL 对性能有影响,特别大的SQL参数多的,调试使用
                             //var sqlString = UtilMethods.GetSqlString(DbType.SqlServer, sql, pars);
                             //Console.WriteLine(sqlString);
                         };
@@ -53,44 +40,46 @@ namespace App.OrmRunner
                 }
                 using SqlSugarClient db = new SqlSugarClient(new ConnectionConfig
                 {
-                    DbType = DbType.Sqlite,
+                    DbType = provider switch { "Sqlite" => DbType.Sqlite, "MySql" => DbType.MySql, "SqlServer" => DbType.SqlServer },
                     ConnectionString = connectionString,
                     IsAutoCloseConnection = true,
                 }, configAction);
-                this.db = db;
 
-                if (config.queryJoin) QueryJoin();
-                else Query();
+
+                if (config.queryJoin) QueryExecute.QueryJoin(db, config);
+                else QueryExecute.Query(db, config);
             }
         }
+    }
+}
 
-        #region Executor
-        int exceptUserId = 1;
-        public void QueryJoin()
-        {
-            var minId = 1;
-            var config = new { maxId = 10000 };
-            var offsetId = 100;
-
-            //var query =
-            //        from user in userSet
-            //        from father in userSet.Where(father => user.fatherId == father.id).DefaultIfEmpty()
-            //        from mother in userSet.Where(mother => user.motherId == mother.id).DefaultIfEmpty()
-            //        where user.id > minId && user.id < config.maxId && user.id != exceptUserId
-            //        orderby user.id
-            //        select new
-            //        {
-            //            user,
-            //            father,
-            //            mother,
-            //            testId = user.id + offsetId,
-            //            hasFather = father.name != null ? true : false
-            //        }
-            //        ;
 
+
+namespace App.OrmRunner.SqlSugerRunner
+{
+
+    // Entity Definition
+    [SugarTable("User")]
+    public class User
+    {
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
+        public int id { get; set; }
+        public string name { get; set; }
+        public DateTime? birth { get; set; }
+        public int? fatherId { get; set; }
+        public int? motherId { get; set; }
+    }
+
+
+
+    public class QueryExecute
+    {
+
+        public static void QueryJoin(SqlSugarClient db, RunConfig config)
+        {
             var query = db.Queryable<User>().LeftJoin<User>((user, father) => user.fatherId == father.id)
                 .LeftJoin<User>((user, father, mother) => user.fatherId == mother.id)
-                .Where((user, father, mother) => user.id > minId && user.id < config.maxId && user.id != exceptUserId)
+                .Where((user, father, mother) => user.id > 1 && user.id < 10000)
                 .OrderBy((user, father, mother) => user.id, OrderByType.Asc)
                 .Select((user, father, mother) =>
                 new
@@ -98,46 +87,35 @@ namespace App.OrmRunner
                     user,
                     father,
                     mother,
-                    testId = user.id + offsetId,
+                    testId = user.id + 100,
                     hasFather = father.name != null ? true : false
                 });
 
 
-            Execute(query);
+            Execute(query, config);
         }
 
-        public void Query()
+        public static void Query(SqlSugarClient db, RunConfig config)
         {
+            var query = db.Queryable<User>().Where(user => user.id > 1 && user.id < 10000).OrderBy(user => user.id, OrderByType.Asc);
 
-            var minId = 1;
-            var config = new { maxId = 10000 };
-
-            //var query =
-            //        from user in userSet
-            //        where user.id > minId && user.id < config.maxId && user.id != exceptUserId
-            //        orderby user.id
-            //        select user;
-
-            var query = db.Queryable<User>().Where(user => user.id > minId && user.id < config.maxId && user.id != exceptUserId).OrderBy(user => user.id, OrderByType.Asc);
-
-            Execute(query);
+            Execute(query, config);
         }
-        #endregion
 
-        public void Execute<Result>(ISugarQueryable<Result> query)
+
+        public static void Execute<Result>(ISugarQueryable<Result> query, RunConfig config)
         {
-            if (skip.HasValue) query = query.Skip(skip.Value);
-            if (take.HasValue) query = query.Take(take.Value);
+            if (config.skip > 0) query = query.Skip(config.skip.Value);
+            query = query.Take(config.take);
 
-            if (executeQuery)
+            if (config.executeQuery)
             {
                 var userList = query.ToList();
                 var rowCount = userList.Count();
-                if (rowCount != take) throw new Exception($"query failed, expected row count : {take} , actual count: {rowCount} ");
+                if (rowCount != config.take) throw new Exception($"query failed, expected row count : {config.take} , actual count: {rowCount} ");
             }
             else
             {
-                sql = null;
                 var count = query.Count();
                 //query.Single();
 
@@ -148,21 +126,5 @@ namespace App.OrmRunner
 
 
 
-
-
-
-        // Entity Definition
-        [SugarTable("User")]
-        public class User
-        {
-            [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
-            public int id { get; set; }
-            public string name { get; set; }
-            public DateTime? birth { get; set; }
-            public int? fatherId { get; set; }
-            public int? motherId { get; set; }
-        }
-
-
     }
 }

+ 39 - 55
test/Vitorm.Data.Benchmark/OrmRunner/Runner_Vitorm.cs

@@ -1,88 +1,84 @@
-using Vitorm;
+using App.OrmRunner.VitormRunner;
+
+using Vitorm;
 
 namespace App.OrmRunner
 {
     public partial class Runner_Vitorm : IRunner
     {
-
-        RunConfig config;
-
-        int? skip => config.skip;
-        int take => config.take;
-        bool executeQuery => config.executeQuery;
-
-
-        IQueryable<User> userQuery;
-        public IQueryable<User> GetQueryable() => userQuery;
-
         public void Run(RunConfig config)
         {
-            this.config = config;
-
             for (int i = 0; i < config.repeatCount; i++)
             {
-                userQuery = Data.Query<User>();
-                if (config.queryJoin) QueryJoin();
-                else Query();
+                var userQuery = Data.Query<User>();
+                if (config.queryJoin) QueryExecute.QueryJoin(userQuery, config);
+                else QueryExecute.Query(userQuery, config);
             }
         }
+    }
+}
 
-        #region Executor
-        int exceptUserId = 1;
-        public void QueryJoin()
-        {
-            var userSet = GetQueryable();
 
-            var minId = 1;
-            var config = new { maxId = 10000 };
-            var offsetId = 100;
+namespace App.OrmRunner.VitormRunner
+{
+    // Entity Definition
+    [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+    public class User
+    {
+        [System.ComponentModel.DataAnnotations.Key]
+        public int id { get; set; }
+        public string name { get; set; }
+        public DateTime? birth { get; set; }
+        public int? fatherId { get; set; }
+        public int? motherId { get; set; }
+
+    }
+
 
+    public class QueryExecute
+    {
+        public static void QueryJoin(IQueryable<User> userSet, RunConfig config)
+        {
             var query =
                     from user in userSet
                     from father in userSet.Where(father => user.fatherId == father.id).DefaultIfEmpty()
                     from mother in userSet.Where(mother => user.motherId == mother.id).DefaultIfEmpty()
-                    where user.id > minId && user.id < config.maxId && user.id != exceptUserId
+                    where user.id > 1 && user.id < 10000
                     orderby user.id
                     select new
                     {
                         user,
                         father,
                         mother,
-                        testId = user.id + offsetId,
+                        testId = user.id + 100,
                         hasFather = father.name != null ? true : false
                     }
                     ;
 
-            Execute(query);
+            Execute(query, config);
         }
 
-        public void Query()
+        public static void Query(IQueryable<User> userSet, RunConfig config)
         {
-            var userSet = GetQueryable();
-
-            var minId = 1;
-            var config = new { maxId = 10000 };
-
             var query =
                     from user in userSet
-                    where user.id > minId && user.id < config.maxId && user.id != exceptUserId
+                    where user.id > 1 && user.id < 10000
                     orderby user.id
                     select user;
 
-            Execute(query);
+            Execute(query, config);
         }
-        #endregion
 
-        public void Execute<Result>(IQueryable<Result> query)
+        public static void Execute<Result>(IQueryable<Result> query, RunConfig config)
         {
-            if (skip > 0) query = query.Skip(skip.Value);
-            query = query.Take(take);
+            if (config.skip > 0) query = query.Skip(config.skip.Value);
+            query = query.Take(config.take);
 
-            if (executeQuery)
+            if (config.executeQuery)
             {
                 var userList = query.ToList();
                 var rowCount = userList.Count();
-                if (rowCount != take) throw new Exception($"query failed, expected row count : {take} , actual count: {rowCount} ");
+                if (rowCount != config.take) throw new Exception($"query failed, expected row count : {config.take} , actual count: {rowCount} ");
             }
             else
             {
@@ -91,18 +87,6 @@ namespace App.OrmRunner
             }
         }
 
-
-        // Entity Definition
-        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
-        public class User
-        {
-            [System.ComponentModel.DataAnnotations.Key]
-            public int id { get; set; }
-            public string name { get; set; }
-            public DateTime? birth { get; set; }
-            public int? fatherId { get; set; }
-            public int? motherId { get; set; }
-        }
-
     }
 }
+

+ 1 - 1
test/Vitorm.Data.Benchmark/Program.cs

@@ -14,7 +14,7 @@ namespace App
 
 
             // #2 
-            //new App.OrmRunner.Runner_Vitorm().Run(new() { take = 100, queryJoin = true, executeQuery = true });
+            //new App.OrmRunner.Runner_Vitorm().Run(new() { take = 1, queryJoin = true, executeQuery = true });
             //new App.OrmRunner.Runner_EntityFramework().Run(new() { take = 100, queryJoin = true, executeQuery = true });
             //new App.OrmRunner.Runner_SqlSuger().Run(new() { repeatCount = 100, take = 1000, queryJoin = true, executeQuery = true });
             //new App.OrmRunner.Runner_SqlSuger().Run(new() { repeatCount = 100, take = 1000, queryJoin = false, executeQuery = true });

+ 9 - 4
test/Vitorm.Data.Benchmark/Vitorm.Data.Benchmark.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
     <PropertyGroup>
         <OutputType>Exe</OutputType>
@@ -10,14 +10,19 @@
 
     <ItemGroup>
       <PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
-      <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.31" />
-      <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.31" />
-      <PackageReference Include="SqlSugarCore" Version="5.1.4.160" />
+      <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.32" />
+      <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.32" />
+      <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.32" />
+      <PackageReference Include="MySql.EntityFrameworkCore" Version="8.0.5" />
+ 
+      <PackageReference Include="SqlSugarCore" Version="5.1.4.162" />
     </ItemGroup>
 
     <ItemGroup>
         <ProjectReference Include="..\..\src\Vitorm.Data\Vitorm.Data.csproj" />
+        <ProjectReference Include="..\..\src\Vitorm.MySql\Vitorm.MySql.csproj" />
         <ProjectReference Include="..\..\src\Vitorm.Sqlite\Vitorm.Sqlite.csproj" />
+        <ProjectReference Include="..\..\src\Vitorm.SqlServer\Vitorm.SqlServer.csproj" />
     </ItemGroup>
 
     <ItemGroup>

+ 24 - 0
test/Vitorm.Data.Console/ProgramMin.cs

@@ -0,0 +1,24 @@
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            //  Query Records
+            var user = Data.Get<User>(1);
+            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}

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

@@ -39,7 +39,7 @@ namespace Vitorm.MsTest
 
         public override User NewUser(int id, bool forAdd = false) => new User { id = id, name = "testUser" + id };
 
-        public override void WaitForUpdate() => Thread.Sleep(1000);
+        public override void WaitForUpdate() => Thread.Sleep(2000);
 
         public void Init()
         {

+ 28 - 0
test/Vitorm.Sqlite.Console/Program_Min.cs

@@ -0,0 +1,28 @@
+using Vitorm;
+namespace App
+{
+    public class Program_Min
+    {
+        static void Main2(string[] args)
+        {
+            // #1 Init
+            using var dbContext = new Vitorm.Sql.SqlDbContext();
+            dbContext.UseSqlite("data source=sqlite.db");
+
+            // #2 Query
+            var user = dbContext.Get<User>(1);
+            var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
+        }
+
+        // Entity Definition
+        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
+        public class User
+        {
+            [System.ComponentModel.DataAnnotations.Key]
+            public int id { get; set; }
+            public string name { get; set; }
+            public DateTime? birth { get; set; }
+            public int? fatherId { get; set; }
+        }
+    }
+}