From 62cbc406a9f5a61eee8eb50681aa5f303e68c72e Mon Sep 17 00:00:00 2001
From: sunkaixuna <610262374@qq.com>
Date: Tue, 1 Feb 2022 12:55:49 +0800
Subject: [PATCH] Add SqlSugar.Access and SqlSugar MySqlConnector
---
Src/Asp.Net/MySqlConnectorTest/App.config | 22 +
.../MySqlConnectorTest/Bugs/BugTest1.cs | 62 ++
Src/Asp.Net/MySqlConnectorTest/Config.cs | 34 +
.../Demo/Demo0_SqlSugarClient.cs | 416 ++++++++++++
.../Demo/Demo1_Queryable.cs | 394 ++++++++++++
.../Demo/Demo2_Updateable.cs | 108 ++++
.../Demo/Demo3_Insertable.cs | 75 +++
.../Demo/Demo4_Deleteable.cs | 48 ++
.../Demo/Demo5_SqlQueryable.cs | 36 ++
.../MySqlConnectorTest/Demo/Demo6_Queue.cs | 52 ++
.../MySqlConnectorTest/Demo/Demo7_Ado.cs | 59 ++
.../MySqlConnectorTest/Demo/Demo8_Saveable.cs | 48 ++
.../Demo/Demo9_EntityMain.cs | 46 ++
.../MySqlConnectorTest/Demo/DemoA_DbMain.cs | 42 ++
.../MySqlConnectorTest/Demo/DemoB_Aop.cs | 68 ++
.../MySqlConnectorTest/Demo/DemoD_DbFirst.cs | 75 +++
.../Demo/DemoE_CodeFirst.cs | 40 ++
.../Demo/DemoF_Utilities.cs | 46 ++
.../Demo/DemoG_SimpleClient.cs | 36 ++
.../MySqlConnectorTest/Demo/DemoJ_Report.cs | 142 ++++
.../Demo/DemoN_SplitTable.cs | 89 +++
.../MySqlConnectorTest/Demo/DemoO_Fastest.cs | 60 ++
.../Demo/Democ_GobalFilter.cs | 77 +++
.../Models/AttributeTable.cs | 20 +
.../MySqlConnectorTest/Models/CarType.cs | 7 +
.../MySqlConnectorTest/Models/Custom.cs | 14 +
.../MySqlConnectorTest/Models/EntityMapper.cs | 15 +
.../MySqlConnectorTest/Models/Mapper.cs | 54 ++
.../Models/MyCustomAttributeTable.cs | 20 +
.../MySqlConnectorTest/Models/Order.cs | 24 +
.../MySqlConnectorTest/Models/OrderItem.cs | 20 +
.../MySqlConnectorTest/Models/TestTree.cs | 17 +
Src/Asp.Net/MySqlConnectorTest/Models/Tree.cs | 20 +
.../Models/Unit/Custom1/EGoods.cs | 604 ++++++++++++++++++
.../Models/Unit/Custom1/EGoodsBrand.cs | 68 ++
.../Models/Unit/Custom1/EGoodsClass.cs | 261 ++++++++
.../Models/Unit/Custom1/EOrderAlbaran.cs | 404 ++++++++++++
.../Unit/Custom1/EOrderAlbaranDetail.cs | 234 +++++++
.../Models/Unit/Custom1/EOrderReturn.cs | 381 +++++++++++
.../Models/Unit/Custom1/EOrderReturnDetail.cs | 202 ++++++
.../Unit/Custom1/PurchaseDetailModel.cs | 162 +++++
.../MySqlConnectorTest/Models/ViewOrder.cs | 13 +
.../MySqlConnectorTest.csproj | 138 ++++
Src/Asp.Net/MySqlConnectorTest/Program.cs | 41 ++
.../Properties/AssemblyInfo.cs | 36 ++
.../MySqlConnectorTest/UnitTest/Main.cs | 50 ++
.../MySqlConnectorTest/UnitTest/UAdo.cs | 57 ++
.../MySqlConnectorTest/UnitTest/UBulkCopy.cs | 212 ++++++
.../MySqlConnectorTest/UnitTest/UCodeFirst.cs | 92 +++
.../MySqlConnectorTest/UnitTest/UCustom06.cs | 45 ++
.../MySqlConnectorTest/UnitTest/UInsert.cs | 154 +++++
.../MySqlConnectorTest/UnitTest/UJson.cs | 39 ++
.../MySqlConnectorTest/UnitTest/UQueryable.cs | 370 +++++++++++
.../UnitTest/UQueryableAsync.cs | 43 ++
.../MySqlConnectorTest/UnitTest/UQueue.cs | 41 ++
.../MySqlConnectorTest/UnitTest/UThread.cs | 376 +++++++++++
.../MySqlConnectorTest/UnitTest/UThread2.cs | 316 +++++++++
.../MySqlConnectorTest/UnitTest/UThread3.cs | 117 ++++
.../MySqlConnectorTest/UnitTest/UValidate.cs | 19 +
.../UnitTest/UnitCustom01.cs | 117 ++++
.../MySqlConnectorTest/UnitTest/Updateable.cs | 211 ++++++
.../MySqlConnectorTest/packages.config | 8 +
.../Properties/AssemblyInfo.cs | 36 ++
Src/Asp.Net/SqlSugar.Access/Queryable.cs | 13 +
.../SqlSugar.Access/SqlSugar.Access.csproj | 54 ++
.../MySql/CodeFirst/MySqlCodeFirst.cs | 80 +++
.../MySql/DbBind/MySqlDbBind.cs | 97 +++
.../MySql/DbFirst/MySqlDbFirst.cs | 11 +
.../MySql/DbMaintenance/MySqlDbMaintenance.cs | 464 ++++++++++++++
.../MySql/MySqlProvider.cs | 140 ++++
.../MySql/Queryable/MySqlQueryable.cs | 60 ++
.../MySql/SqlBuilder/MySqlBlukCopy.cs | 202 ++++++
.../MySql/SqlBuilder/MySqlBuilder.cs | 26 +
.../MySql/SqlBuilder/MySqlDeleteBuilder.cs | 7 +
.../SqlBuilder/MySqlExpressionContext.cs | 154 +++++
.../MySql/SqlBuilder/MySqlFastBuilder.cs | 74 +++
.../MySql/SqlBuilder/MySqlInsertBuilder.cs | 136 ++++
.../MySql/SqlBuilder/MySqlQueryBuilder.cs | 138 ++++
.../MySql/SqlBuilder/MySqlUpdateBuilder.cs | 155 +++++
.../Properties/AssemblyInfo.cs | 36 ++
.../SqlSugar.MySqlConnector.csproj | 93 +++
.../Tools/ErrorMessage.cs | 64 ++
.../Tools/FileHelper.cs | 70 ++
.../Tools/UtilConstants.cs | 73 +++
.../Tools/UtilExtensions.cs | 123 ++++
.../Tools/UtilMethods.cs | 493 ++++++++++++++
.../Tools/ValidateExtensions.cs | 172 +++++
.../SqlSugar.MySqlConnector/packages.config | 8 +
Src/Asp.Net/SqlSugar.sln | 22 +-
.../SugarProvider/SqlSugarAccessory.cs | 5 +
.../Infrastructure/InstanceFactory.cs | 46 +-
91 files changed, 10143 insertions(+), 6 deletions(-)
create mode 100644 Src/Asp.Net/MySqlConnectorTest/App.config
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Bugs/BugTest1.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Config.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo0_SqlSugarClient.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo1_Queryable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo2_Updateable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo3_Insertable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo4_Deleteable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo5_SqlQueryable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo6_Queue.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo7_Ado.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo8_Saveable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Demo9_EntityMain.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoA_DbMain.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoB_Aop.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoD_DbFirst.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoE_CodeFirst.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoF_Utilities.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoG_SimpleClient.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoJ_Report.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoN_SplitTable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/DemoO_Fastest.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Demo/Democ_GobalFilter.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/AttributeTable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/CarType.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Custom.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/EntityMapper.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Mapper.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/MyCustomAttributeTable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Order.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/OrderItem.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/TestTree.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Tree.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoods.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsBrand.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsClass.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaran.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaranDetail.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturn.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturnDetail.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/PurchaseDetailModel.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Models/ViewOrder.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/MySqlConnectorTest.csproj
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Program.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/Properties/AssemblyInfo.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/Main.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UAdo.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UBulkCopy.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UCodeFirst.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UCustom06.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UInsert.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UJson.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UQueryable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UQueryableAsync.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UQueue.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UThread.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UThread2.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UThread3.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UValidate.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/UnitCustom01.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/UnitTest/Updateable.cs
create mode 100644 Src/Asp.Net/MySqlConnectorTest/packages.config
create mode 100644 Src/Asp.Net/SqlSugar.Access/Properties/AssemblyInfo.cs
create mode 100644 Src/Asp.Net/SqlSugar.Access/Queryable.cs
create mode 100644 Src/Asp.Net/SqlSugar.Access/SqlSugar.Access.csproj
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/CodeFirst/MySqlCodeFirst.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/DbBind/MySqlDbBind.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/DbFirst/MySqlDbFirst.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/DbMaintenance/MySqlDbMaintenance.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/MySqlProvider.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/Queryable/MySqlQueryable.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlBlukCopy.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlBuilder.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlDeleteBuilder.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlExpressionContext.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlFastBuilder.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlInsertBuilder.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlQueryBuilder.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/MySql/SqlBuilder/MySqlUpdateBuilder.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Properties/AssemblyInfo.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/SqlSugar.MySqlConnector.csproj
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Tools/ErrorMessage.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Tools/FileHelper.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Tools/UtilConstants.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Tools/UtilExtensions.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Tools/UtilMethods.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/Tools/ValidateExtensions.cs
create mode 100644 Src/Asp.Net/SqlSugar.MySqlConnector/packages.config
diff --git a/Src/Asp.Net/MySqlConnectorTest/App.config b/Src/Asp.Net/MySqlConnectorTest/App.config
new file mode 100644
index 000000000..8995ddae5
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/App.config
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Src/Asp.Net/MySqlConnectorTest/Bugs/BugTest1.cs b/Src/Asp.Net/MySqlConnectorTest/Bugs/BugTest1.cs
new file mode 100644
index 000000000..d7f8e6ef0
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Bugs/BugTest1.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+namespace OrmTest.Test
+{
+ public class BugTest1
+
+ {
+
+
+
+ public static void Init()
+
+ {
+
+ SqlSugarClient db = new SqlSugarClient(
+
+ new ConnectionConfig()
+
+ {
+
+ ConnectionString = Config.ConnectionString,
+
+ DbType = DbType.MySqlConnector,//设置数据库类型
+
+ IsAutoCloseConnection = true,//自动释放数据务,如果存在事务,在事务结束后释放
+
+ InitKeyType = InitKeyType.Attribute //从实体特性中读取主键自增列信息
+
+ });
+
+ db.Aop.OnError = (exp) =>//SQL报错
+
+ {
+
+ string sql = exp.Sql;
+
+ //exp.sql 这样可以拿到错误SQL
+
+ };
+
+ //db.DbMaintenance.CreateDatabase();
+
+ db.Deleteable().ExecuteCommand();
+ db.Insertable(new Order() { CreateTime = DateTime.Now.Date.AddDays(-1), Name = "1a", Price = 1, CustomId = 1 }).ExecuteCommand();
+ db.Insertable(new Order() { CreateTime = DateTime.Now.Date.AddDays(-1).AddHours(23), Name = "1a", Price = 1, CustomId = 1 }).ExecuteCommand();
+
+ db.Insertable(new Order() { CreateTime = DateTime.Now.Date.AddDays(1), Name = "1a", Price = 1, CustomId = 1 }).ExecuteCommand();
+ db.Insertable(new Order() { CreateTime = DateTime.Now.Date.AddDays(2), Name = "1a", Price = 1, CustomId = 1 }).ExecuteCommand();
+ var s =DateTime.Now.Date.AddMilliseconds(-1);
+ var list= db.Queryable().Where(it => SqlFunc.DateIsSame(it.CreateTime,s)).ToList();
+ var s2 = DateTime.Now.Date.AddDays(-1);
+ var lists = db.Queryable().Where(it => SqlFunc.DateIsSame(it.CreateTime, s2)).ToSql();
+ Console.ReadKey();
+
+ }
+
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Config.cs b/Src/Asp.Net/MySqlConnectorTest/Config.cs
new file mode 100644
index 000000000..f2f301882
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Config.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ ///
+ /// Setting up the database name does not require you to create the database
+ /// 设置好数据库名不需要你去手动建库
+ ///
+ public class Config
+ {
+ ///
+ /// Account have permission to create database
+ /// 用有建库权限的数据库账号
+ ///
+ public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql";
+ ///
+ /// Account have permission to create database
+ /// 用有建库权限的数据库账号
+ ///
+ public static string ConnectionString2 = "server=localhost;Database=SqlSugar4xTest2;Uid=root;Pwd=haosql";
+ ///
+ /// Account have permission to create database
+ /// 用有建库权限的数据库账号
+ ///
+ public static string ConnectionString3 = "server=localhost;Database=SqlSugar4xTest3;Uid=root;Pwd=haosql";
+
+
+ /***注意:如果报错:指字关键词不在字典中这说明需要更新MYSQL.DATA驱动到最新,不报错就不需要更新***/
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo0_SqlSugarClient.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo0_SqlSugarClient.cs
new file mode 100644
index 000000000..2004dd87b
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo0_SqlSugarClient.cs
@@ -0,0 +1,416 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+namespace OrmTest
+{
+ public class Demo0_SqlSugarClient
+ {
+
+ public static void Init()
+ {
+ SqlSugarClient();//Create db
+ DbContext();//Optimizing SqlSugarClient usage
+ SingletonPattern();//Singleten Pattern
+ DistributedTransactionExample();
+ MasterSlave();//Read-write separation
+ CustomAttribute();
+ }
+
+ private static void MasterSlave()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### MasterSlave Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = Config.ConnectionString,//Master Connection
+ DbType = DbType.MySqlConnector,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ SlaveConnectionConfigs = new List() {
+ new SlaveConnectionConfig() { HitRate=10, ConnectionString=Config.ConnectionString2 } ,
+ new SlaveConnectionConfig() { HitRate=10, ConnectionString=Config.ConnectionString2 }
+ }
+ });
+ db.Aop.OnLogExecuted = (s, p) =>
+ {
+ Console.WriteLine(db.Ado.Connection.ConnectionString);
+ };
+ Console.WriteLine("Master:");
+ db.Insertable(new Order() { Name = "abc", CustomId = 1, CreateTime = DateTime.Now }).ExecuteCommand();
+ Console.WriteLine("Slave:");
+ db.Queryable().First();
+ Console.WriteLine("#### MasterSlave End ####");
+ }
+
+ private static void SqlSugarClient()
+ {
+ //Create db
+ Console.WriteLine("#### SqlSugarClient Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+ //If no exist create datebase
+ db.DbMaintenance.CreateDatabase();
+
+ //Use db query
+ var dt = db.Ado.GetDataTable("select 1");
+
+ //Create tables
+ db.CodeFirst.InitTables(typeof(OrderItem),typeof(Order));
+ var id = db.Insertable(new Order() { Name = "order1", CustomId = 1, Price = 0, CreateTime = DateTime.Now }).ExecuteReturnIdentity();
+
+ //Insert data
+ db.Insertable(new OrderItem() { OrderId = id, Price = 0, CreateTime=DateTime.Now }).ExecuteCommand();
+ Console.WriteLine("#### SqlSugarClient End ####");
+
+ }
+
+ private static void DbContext()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### DbContext Start ####");
+ var insertObj = new Order { Name = "jack", CreateTime = DateTime.Now };
+ var InsertObjs = new Order[] { insertObj };
+
+ DbContext context = new DbContext();
+
+ context.Db.CodeFirst.InitTables();//Create Tables
+ ;
+ var orderDb = context.OrderDb;
+
+ //Select
+ var data1 = orderDb.GetById(1);
+ var data2 = orderDb.GetList();
+ var data3 = orderDb.GetList(it => it.Id == 1);
+ var data4 = orderDb.GetSingle(it => it.Id == 1);
+ var p = new PageModel() { PageIndex = 1, PageSize = 2 };
+ var data5 = orderDb.GetPageList(it => it.Name == "xx", p);
+ Console.Write(p.TotalCount);
+ var data6 = orderDb.GetPageList(it => it.Name == "xx", p, it => it.Name, OrderByType.Asc);
+ Console.Write(p.TotalCount);
+ List conModels = new List();
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1" });//id=1
+ var data7 = orderDb.GetPageList(conModels, p, it => it.Name, OrderByType.Asc);
+ orderDb.AsQueryable().Where(x => x.Id == 1).ToList();
+
+ //Insert
+ orderDb.Insert(insertObj);
+ orderDb.InsertRange(InsertObjs);
+ var id = orderDb.InsertReturnIdentity(insertObj);
+ orderDb.AsInsertable(insertObj).ExecuteCommand();
+
+
+ //Delete
+ orderDb.Delete(insertObj);
+ orderDb.DeleteById(11111);
+ orderDb.DeleteById(new int[] { 1111, 2222 });
+ orderDb.Delete(it => it.Id == 1111);
+ orderDb.AsDeleteable().Where(it => it.Id == 1111).ExecuteCommand();
+
+ //Update
+ orderDb.Update(insertObj);
+ orderDb.UpdateRange(InsertObjs);
+ orderDb.Update(it => new Order() { Name = "a", }, it => it.Id == 1);
+ orderDb.AsUpdateable(insertObj).UpdateColumns(it => new { it.Name }).ExecuteCommand();
+
+ //Use Inherit DbContext
+ OrderDal dal = new OrderDal();
+ var data = dal.GetById(1);
+ var list = dal.GetList();
+
+ Console.WriteLine("#### DbContext End ####");
+ }
+
+ private static void CustomAttribute()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Custom Attribute Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = Config.ConnectionString,
+ DbType = DbType.MySqlConnector,
+ IsAutoCloseConnection = true,
+ InitKeyType = InitKeyType.Attribute,
+ ConfigureExternalServices = new ConfigureExternalServices()
+ {
+ EntityService = (property, column) =>
+ {
+
+ var attributes = property.GetCustomAttributes(true);//get all attributes
+
+ if (attributes.Any(it => it is KeyAttribute))// by attribute set primarykey
+ {
+ column.IsPrimarykey = true;
+ }
+ },
+ EntityNameService = (type, entity) =>
+ {
+ var attributes = type.GetCustomAttributes(true);
+ if (attributes.Any(it => it is TableAttribute))
+ {
+ entity.DbTableName = (attributes.First(it => it is TableAttribute) as TableAttribute).Name;
+ }
+ }
+ }
+ });
+ db.CodeFirst.InitTables();//Create Table
+
+ db.Insertable(new AttributeTable() { Id = Guid.NewGuid().ToString(), Name = "Name" }).ExecuteCommand();
+ var list = db.Queryable().ToList();
+
+ Console.WriteLine("#### Custom Attribute End ####");
+ }
+
+
+ private static void SingletonPattern()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Singleton Pattern Start ####");
+ Console.WriteLine("Db_Id:" + singleDb.ContextID);
+ Console.WriteLine("Db_Id:" + singleDb.ContextID);
+ var task = new Task(() =>
+ {
+ Console.WriteLine("Task DbId:" + singleDb.ContextID);
+ new Task(() =>
+ {
+ Console.WriteLine("_Task_Task DbId:" + singleDb.ContextID);
+ Console.WriteLine("_Task_Task DbId:" + singleDb.ContextID);
+
+ }).Start();
+ Console.WriteLine("Task DbId:" + singleDb.ContextID);
+ });
+ task.Start();
+ task.Wait();
+ System.Threading.Thread.Sleep(500);
+ Console.WriteLine(string.Join(",", singleDb.TempItems.Keys));
+
+ Console.WriteLine("#### Singleton Pattern end ####");
+ }
+
+ static SqlSugarScope singleDb = new SqlSugarScope(
+ new ConnectionConfig()
+ {
+ ConfigId = 1,
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents()
+ {
+ OnLogExecuting = (sql, p) => { Console.WriteLine(sql); }
+ }
+ });
+
+
+ private static void DistributedTransactionExample()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Distributed TransactionExample Start ####");
+ SqlSugarClient db = new SqlSugarClient(new List()
+ {
+ new ConnectionConfig(){ ConfigId="1", DbType=DbType.MySqlConnector, ConnectionString=Config.ConnectionString,InitKeyType=InitKeyType.Attribute,IsAutoCloseConnection=true },
+ new ConnectionConfig(){ ConfigId="2", DbType=DbType.MySqlConnector, ConnectionString=Config.ConnectionString2 ,InitKeyType=InitKeyType.Attribute ,IsAutoCloseConnection=true}
+ });
+
+ //use db1
+ db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Order), typeof(OrderItem));//
+ db.Insertable(new Order() { Name = "order1", CreateTime = DateTime.Now }).ExecuteCommand();
+ Console.WriteLine(db.CurrentConnectionConfig.DbType + ":" + db.Queryable().Count());
+
+ //use db2
+ db.ChangeDatabase("2");
+ db.DbMaintenance.CreateDatabase();//Create Database2
+ db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Order), typeof(OrderItem));
+ db.Insertable(new Order() { Name = "order1", CreateTime = DateTime.Now }).ExecuteCommand();
+ Console.WriteLine(db.CurrentConnectionConfig.DbType + ":" + db.Queryable().Count());
+
+ // Example 1
+ Console.WriteLine("Example 1");
+ try
+ {
+ db.BeginTran();
+
+ db.ChangeDatabase("1");//use db1
+ db.Deleteable().ExecuteCommand();
+ Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ db.ChangeDatabase("2");//use db2
+ db.Deleteable().ExecuteCommand();
+ Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ throw new Exception();
+ db.CommitTran();
+ }
+ catch
+ {
+ db.RollbackTran();
+ Console.WriteLine("---Roll back");
+ db.ChangeDatabase("1");//use db1
+ Console.WriteLine(db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ db.ChangeDatabase("2");//use db2
+ Console.WriteLine(db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+ }
+
+
+
+ // Example 2
+ Console.WriteLine("Example 2");
+
+ var result=db.UseTran(() =>
+ {
+
+ db.ChangeDatabase("1");//use db1
+ db.Deleteable().ExecuteCommand();
+ Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ db.ChangeDatabase("2");//use db2
+ db.Deleteable().ExecuteCommand();
+ Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+ throw new Exception("");
+
+ });
+ if (result.IsSuccess == false) {
+ Console.WriteLine("---Roll back");
+ db.ChangeDatabase("1");//use db1
+ Console.WriteLine(db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ db.ChangeDatabase("2");//use db2
+ Console.WriteLine(db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+ }
+
+ // Example 3
+ Console.WriteLine("Example 3");
+
+ var result2 = db.UseTranAsync(async () =>
+ {
+
+ db.ChangeDatabase("1");//use db1
+ await db.Deleteable().ExecuteCommandAsync();
+ Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ db.ChangeDatabase("2");//use db2
+ await db.Deleteable().ExecuteCommandAsync();
+ Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+ throw new Exception("");
+
+ });
+ result2.Wait();
+ if (result2.Result.IsSuccess == false)
+ {
+ Console.WriteLine("---Roll back");
+ db.ChangeDatabase("1");//use sqlserver
+ Console.WriteLine(db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+
+ db.ChangeDatabase("2");//use mysql
+ Console.WriteLine(db.CurrentConnectionConfig.DbType);
+ Console.WriteLine(db.Queryable().Count());
+ }
+
+ Console.WriteLine("#### Distributed TransactionExample End ####");
+ }
+ }
+
+ ///
+ /// DbContext Example 1
+ ///
+ public class DbContext
+ {
+
+ public SqlSugarClient Db;
+ public DbContext()
+ {
+ Db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = Config.ConnectionString,
+ DbType = DbType.MySqlConnector,
+ IsAutoCloseConnection = true,
+ InitKeyType = InitKeyType.Attribute,
+ AopEvents = new AopEvents()
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ }
+ }
+ });
+ }
+ public SimpleClient OrderDb => new SimpleClient(Db);
+ public SimpleClient OrderItemDb => new SimpleClient(Db);
+ }
+
+
+ public class OrderDal : DbContext
+ {
+
+ }
+ ///
+ /// DbContext Example 2
+ ///
+ ///
+ public class DbContext where T : class, new()
+ {
+
+ public SqlSugarClient Db;
+ public DbContext()
+ {
+ Db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = Config.ConnectionString,
+ DbType = DbType.MySqlConnector,
+ IsAutoCloseConnection = true,
+ InitKeyType = InitKeyType.Attribute,
+ AopEvents = new AopEvents()
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ }
+ }
+ });
+ }
+ public SimpleClient CurrentDb => new SimpleClient(Db);
+ public virtual T GetById(int id)
+ {
+ return CurrentDb.GetById(id);
+ }
+ public virtual List GetList()
+ {
+ return CurrentDb.GetList();
+ }
+ public virtual bool Delete(int id)
+ {
+ return CurrentDb.DeleteById(id);
+ }
+ }
+
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo1_Queryable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo1_Queryable.cs
new file mode 100644
index 000000000..542114a6e
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo1_Queryable.cs
@@ -0,0 +1,394 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Dynamic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ public class Demo1_Queryable
+ {
+
+ public static void Init()
+ {
+ EasyExamples();
+ QueryConditions();
+ JoinTable();
+ Async();
+ NoEntity();
+ Mapper();
+ SqlFuncTest();
+ Subquery();
+ ReturnType();
+ ConfiQuery();
+ }
+ private static void ConfiQuery()
+ {
+ var db = GetInstance();
+ db.ConfigQuery.SetTable(it => it.Id, it => it.Name, "01", it => it.Id > 1);
+ db.ConfigQuery.SetTable(it => it.Id, it => it.Name, "02", it => it.Id > 2);
+ db.ConfigQuery.SetTable(it => it.Id, it => it.Name, null);
+ var list = db.Queryable().Select(it => new OrderItem
+ {
+ ItemId = it.ItemId.SelectAll(),
+ OrderName = it.OrderId.GetConfigValue("01")
+ }).ToList();
+ var list2 = db.Queryable().Select(it => new OrderItem
+ {
+ ItemId = it.ItemId.SelectAll(),
+ OrderName = it.OrderId.GetConfigValue("02")
+ }).ToList();
+ var list3 = db.Queryable().Select(it => new OrderItem
+ {
+ ItemId = it.ItemId.SelectAll(),
+ OrderName = it.OrderId.GetConfigValue()
+ }).ToList();
+
+ var list4 = db.Queryable().Select(it => new OrderItem
+ {
+ ItemId = it.ItemId.SelectAll(),
+ OrderName = it.OrderId.GetConfigValue()
+ })
+ .Where(it => it.OrderId.GetConfigValue() == "order1")
+ .OrderBy(it => it.OrderId.GetConfigValue()).ToList();
+
+ var list5 = db.Queryable((o, i) => o.Id == i.OrderId)
+ .OrderBy((o, i) => i.OrderId.GetConfigValue(), OrderByType.Desc)
+ .Select((o, i) => new ViewOrder()
+ {
+ Id = o.Id.SelectAll(),
+ Name = i.OrderId.GetConfigValue()
+ })
+ .ToList();
+ }
+ private static void EasyExamples()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Examples Start ####");
+ var db = GetInstance();
+ var dbTime = db.GetDate();
+ var getAll = db.Queryable().ToList();
+ var getAll2 = db.Queryable().Where(it=>it.CreateTime.Day>=DateTime.Now.Date.Day).ToList();
+ var getOrderBy = db.Queryable().OrderBy(it => it.Name,OrderByType.Desc).ToList();
+ var getOrderBy2 = db.Queryable().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList();
+ var getOrderBy3 = db.Queryable().OrderBy(it =>new { it.Name,it.Id}).ToList();
+ var getRandom = db.Queryable().OrderBy(it => SqlFunc.GetRandom()).First();
+ var getByPrimaryKey = db.Queryable().InSingle(2);
+ var getSingleOrDefault = db.Queryable().Where(it => it.Id == 1).Single();
+ var getFirstOrDefault = db.Queryable().First();
+ var getByWhere = db.Queryable().Where(it => it.Id == 1 || it.Name == "a").ToList();
+ var getByWhere2 = db.Queryable().Where(it => it.Id == DateTime.Now.Year).ToList();
+ var getByFuns = db.Queryable().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
+ var getByFuns2 = db.Queryable().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList();
+ var dp = DateTime.Now;
+ var test05 = db.Queryable().Where(it => it.CreateTime.Month == dp.Month).ToList();
+ var fromatList = db.Queryable().Select(it => it.CreateTime.ToString("%Y-%m")).ToList();
+ var test06 = db.Queryable().Where(it => it.CreateTime.Date.Day >= DateTime.Now.Date.Day).ToList();
+ Console.WriteLine("#### Examples End ####");
+ }
+
+ private static void ReturnType()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### ReturnType Start ####");
+ var db = GetInstance();
+ List list = db.Queryable().ToList();
+
+ Order item = db.Queryable().First(it => it.Id == 1);
+
+ DataTable dataTable = db.Queryable().Select(it => it.Id).ToDataTable();
+
+ var json = db.Queryable().ToJson();
+
+ List listInt = db.Queryable().Select(it => it.Id).ToList();
+
+ var dynamic = db.Queryable().Select().ToList();
+
+ var viewModel = db.Queryable((o, i, c) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId ,
+ JoinType.Left, o.CustomId == c.Id
+ ))
+ .Select().ToList();
+
+ var newDynamic = db.Queryable((o, i, c) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId,
+ JoinType.Left, o.CustomId == c.Id
+ ))
+ .Select((o, i, c) => new { orderName = o.Name, cusName=c.Name }).ToList();
+
+ var newClass = db.Queryable((o, i, c) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId,
+ JoinType.Left, o.CustomId == c.Id
+ ))
+ .Select((o, i, c) => new ViewOrder { Name=o.Name, CustomName=c.Name }).ToList();
+
+
+ var oneClass = db.Queryable((o, i, c) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId,
+ JoinType.Left, o.CustomId == c.Id
+ ))
+ .Select((o, i, c) => c).ToList();
+
+ var twoClass = db.Queryable((o, i, c) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId,
+ JoinType.Left, o.CustomId == c.Id
+ ))
+ .Select((o, i, c) => new { o,i}).ToList();
+
+
+ var mergeList= db.Queryable()
+ .Select(it => new { id = it.Id })
+ .MergeTable().Select().ToList();
+
+ Console.WriteLine("#### ReturnType End ####");
+ }
+
+ private static void Subquery()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Subquery Start ####");
+ var db = GetInstance();
+
+ var list = db.Queryable().Take(10).Select(it => new
+ {
+ customName=SqlFunc.Subqueryable().Where("it.CustomId=id").Select(s=>s.Name),
+ customName2 = SqlFunc.Subqueryable().Where("it.CustomId = id").Where(s => true).Select(s => s.Name)
+ }).ToList();
+
+ var list2 = db.Queryable().Where(it => SqlFunc.Subqueryable().Where(i => i.OrderId == it.Id).Any()).ToList();
+
+ Console.WriteLine("#### Subquery End ####");
+ }
+
+ private static void SqlFuncTest()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### SqlFunc Start ####");
+ var db = GetInstance();
+ var index= db.Queryable().Select(it => SqlFunc.CharIndex("a", "cccacc")).First();
+ var list2 = db.Queryable().Select(it => new
+ {
+ date = SqlFunc.ToDateShort(it.CreateTime),
+ datetime = SqlFunc.ToDate(it.CreateTime)
+ }).ToList();
+ Console.WriteLine("#### SqlFunc End ####");
+ }
+
+ private static void Mapper()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Mapper Start ####");
+ var db = GetInstance();
+ //Creater Table
+ db.CodeFirst.InitTables(typeof(Tree));
+ db.DbMaintenance.TruncateTable("tree");
+ db.Insertable(new Tree() { Id = 1, Name = "root" }).ExecuteCommand();
+ db.Insertable(new Tree() { Id = 11, Name = "child1",ParentId=1 }).ExecuteCommand();
+ db.Insertable(new Tree() { Id = 12, Name = "child2",ParentId=1 }).ExecuteCommand();
+ db.Insertable(new Tree() { Id = 2, Name = "root" }).ExecuteCommand();
+ db.Insertable(new Tree() { Id = 22, Name = "child3", ParentId = 2 }).ExecuteCommand();
+ db.Insertable(new Tree() { Id = 222, Name = "child222", ParentId = 22 }).ExecuteCommand();
+ // Same property name mapping,Both entities have parentId
+ var list = db.Queryable().Mapper(it => it.Parent, it => it.ParentId).ToList();
+
+
+ //If both entities have parentId, I don't want to associate with parentId.
+ var list1 =db.Queryable()
+ //parent=(select * from parent where id=it.parentid)
+ .Mapper(it=>it.Parent,it=>it.ParentId, it=>it.Parent.Id)
+ //Child=(select * from parent where ParentId=it.id)
+ .Mapper(it => it.Child, it => it.Id, it => it.Parent.ParentId)
+ .ToList();
+ //one to one
+ var list2 = db.Queryable().Mapper(it => it.Order, it => it.OrderId).ToList();
+
+ //one to many
+ var list3 = db.Queryable().Mapper(it => it.Items, it => it.Items.First().OrderId).ToList();
+
+ //many to many
+ db.CodeFirst.InitTables();
+
+ db.Insertable(new A() { Name = "A" }).ExecuteCommand();
+ db.Insertable(new B() { Name = "B" }).ExecuteCommand();
+ db.Insertable(new ABMapping() { AId = 1, BId = 1 }).ExecuteCommand();
+
+ var list4 = db.Queryable()
+ .Mapper(it => it.A, it => it.AId)
+ .Mapper(it => it.B, it => it.BId).ToList();
+
+ //Manual mode
+ var result = db.Queryable().Take(10).Select().Mapper((itemModel, cache) =>
+ {
+ var allItems = cache.Get(orderList => {
+ var allIds = orderList.Select(it => it.Id).ToList();
+ return db.Queryable().Where(it => allIds.Contains(it.OrderId)).ToList();//Execute only once
+ });
+ itemModel.Items = allItems.Where(it => it.OrderId==itemModel.Id).ToList();//Every time it's executed
+ }).ToList();
+
+
+ var tree = db.Queryable().ToTree(it => it.Child, it => it.ParentId, 0);
+ var parentList = db.Queryable().ToParentList(it => it.ParentId, 22);
+ var parentList2 = db.Queryable().ToParentList(it => it.ParentId, 222);
+ var parentList3 = db.Queryable().ToParentList(it => it.ParentId, 2);
+ Console.WriteLine("#### End Start ####");
+ }
+
+ private static void NoEntity()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### No Entity Start ####");
+ var db = GetInstance();
+
+ var list = db.Queryable().AS("order").Where("id=id", new { id = 1 }).ToList();
+
+ var list2 = db.Queryable("o").AS("order").AddJoinInfo("OrderDetail", "i", "o.id=i.OrderId").Where("id=id", new { id = 1 }).Select("o.*").ToList();
+ Console.WriteLine("#### No Entity End ####");
+ }
+
+ private static void JoinTable()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Join Table Start ####");
+ var db = GetInstance();
+
+ //Simple join
+ var list = db.Queryable((o, i, c) => o.Id == i.OrderId&&c.Id == o.CustomId)
+ .Select()
+ .ToList();
+
+ //Join table
+ var list2 = db.Queryable((o, i, c) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId,
+ JoinType.Left, c.Id == o.CustomId
+ ))
+ .Select().ToList();
+
+ //Join queryable
+ var query1 = db.Queryable((o, i) => new JoinQueryInfos(
+ JoinType.Left, o.Id == i.OrderId
+ ))
+ .Where(o => o.Name == "jack");
+
+ var query2 = db.Queryable();
+ var list3=db.Queryable(query1, query2,JoinType.Left, (p1, p2) => p1.CustomId == p2.Id).Select().ToList();
+
+ Console.WriteLine("#### Join Table End ####");
+ }
+
+ private static void QueryConditions()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Query Conditions Start ####");
+
+ SqlSugarClient db = GetInstance();
+
+ /*** By expression***/
+
+ //id=@id
+ var list = db.Queryable().Where(it => it.Id == 1).ToList();
+ //id=@id or name like '%'+@name+'%'
+ var list2 = db.Queryable().Where(it => it.Id == 1 || it.Name.Contains("jack")).ToList();
+
+
+ //Create expression
+ var exp = Expressionable.Create()
+ .And(it => it.Id == 1)
+ .Or(it => it.Name.Contains("jack")).ToExpression();
+ var list3 = db.Queryable().Where(exp).ToList();
+
+
+ /*** By sql***/
+
+ //id=@id
+ var list4 = db.Queryable().Where("id=@id", new { id = 1 }).ToList();
+ //id=@id or name like '%'+@name+'%'
+ var list5 = db.Queryable().Where("id=@id or name like @name ", new { id = 1, name = "%jack%" }).ToList();
+
+
+
+ /*** By dynamic***/
+
+ //id=1
+ var conModels = new List();
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1" });//id=1
+ var student = db.Queryable().Where(conModels).ToList();
+
+ //Complex use case
+ List Order = new List();
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1" });//id=1
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Like, FieldValue = "1" });// id like '%1%'
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.IsNullOrEmpty });
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.In, FieldValue = "1,2,3" });
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.NotIn, FieldValue = "1,2,3" });
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.NoEqual, FieldValue = "1,2,3" });
+ conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.IsNot, FieldValue = null });// id is not null
+
+ conModels.Add(new ConditionalCollections()
+ {
+ ConditionalList = new List>()// (id=1 or id=2 and id=1)
+ {
+ //new KeyValuePair( WhereType.And ,new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1" }),
+ new KeyValuePair (WhereType.Or,new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "2" }),
+ new KeyValuePair ( WhereType.And,new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "2" })
+ }
+ });
+ var list6 = db.Queryable().Where(conModels).ToList();
+
+ /*** Conditional builder ***/
+
+ // use whereif
+ string name = "";
+ int id = 1;
+ var query = db.Queryable()
+ .WhereIF(!string.IsNullOrEmpty(name), it => it.Name.Contains(name))
+ .WhereIF(id > 0, it => it.Id == id).ToList();
+ //clone new Queryable
+ var query2 = db.Queryable().Where(it => it.Id == 1);
+ var list7 = query2.Clone().Where(it => it.Name == "jack").ToList();//id=1 and name = jack
+ var list8 = query2.Clone().Where(it => it.Name == "tom").ToList();//id=1 and name = tom
+
+ Console.WriteLine("#### Condition Screening End ####");
+
+
+
+ }
+
+ private static void Async()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Async Start ####");
+
+ SqlSugarClient db = GetInstance();
+ var task1 = db.Queryable().FirstAsync();
+ task1.Wait();
+ var task2 = db.Queryable().Where(it => it.Id == 1).ToListAsync();
+
+
+ task2.Wait();
+
+ Console.WriteLine("#### Async End ####");
+ }
+
+ private static SqlSugarClient GetInstance()
+ {
+ return new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = SqlSugar.DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo2_Updateable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo2_Updateable.cs
new file mode 100644
index 000000000..8333efc99
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo2_Updateable.cs
@@ -0,0 +1,108 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo2_Updateable
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Updateable Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+
+
+ /*** 1.entity or List ***/
+
+ var updateObj = new Order() { Id = 1, Name = "order1" };
+ var updateObjs = new List {
+ new Order() { Id = 11, Name = "order11" },
+ new Order() { Id = 12, Name = "order12" }
+ };
+
+ //update all columns by primary key
+ var result = db.Updateable(updateObj).ExecuteCommand();//update single
+ var result2 = db.Updateable(updateObjs).ExecuteCommand();//update List
+
+ //Ignore Name and Price
+ var result3 = db.Updateable(updateObj).IgnoreColumns(it => new { it.CreateTime, it.Price }).ExecuteCommand();
+
+ //only update Name and CreateTime
+ var result4 = db.Updateable(updateObj).UpdateColumns(it => new { it.Name, it.CreateTime }).ExecuteCommand();
+
+ //If there is no primary key
+ var result5 = db.Updateable(updateObj).WhereColumns(it => new { it.Id }).ExecuteCommand();//update single by id
+ var result6 = db.Updateable(updateObjs).WhereColumns(it => new { it.Id }).ExecuteCommand();//update List by id
+
+
+
+
+ /*** 2.by expression ***/
+
+ //update name,createtime
+ var result7 = db.Updateable(it => new Order() { Name = "a", CreateTime = DateTime.Now }).Where(it => it.Id == 11).ExecuteCommand();
+ var result71 = db.Updateable().SetColumns(it => new Order() { Name = "a", CreateTime = DateTime.Now }).Where(it => it.Id == 11).ExecuteCommand();
+ //only update name
+ var result8 = db.Updateable(it => it.Name == "Name" + "1").Where(it => it.Id == 1).ExecuteCommand();
+ var result81 = db.Updateable().SetColumns(it => it.Name == "Name" + "1").Where(it => it.Id == 1).ExecuteCommand();
+ //
+
+
+
+
+ /*** 3.by Dictionary ***/
+ var dt = new Dictionary();
+ dt.Add("id", 1);
+ dt.Add("name", "abc");
+ dt.Add("createTime", DateTime.Now);
+ var dtList = new List>();
+ dtList.Add(dt);
+
+ var t66 = db.Updateable(dt).AS("`order`").WhereColumns("id").ExecuteCommand();
+ var t666 = db.Updateable(dtList).AS("`order`").WhereColumns("id").ExecuteCommand();
+
+
+
+ /*** 4.Other instructions ***/
+
+ var caseValue = "1";
+ //Do not update NULL columns
+ db.Updateable(updateObj).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
+
+ //if 1 update name else if 2 update name,createtime
+ db.Updateable(updateObj)
+ .UpdateColumnsIF(caseValue == "1", it => new { it.Name })
+ .UpdateColumnsIF(caseValue == "2", it => new { it.Name, it.CreateTime })
+ .ExecuteCommand();
+ //Use Lock
+ db.Updateable(updateObj).With(SqlWith.UpdLock).ExecuteCommand();
+
+ //Where Sql
+ //db.Updateable(updateObj).Where("id=@x", new { x = "1" }).ExecuteCommand();
+ var dataTable = db.Queryable().Select("id,name,1 as price").Take(2).ToDataTable();
+ db.Fastest().BulkUpdate("Order", dataTable, new string[] { "id" }, new string[] { "name" });
+ Console.WriteLine("#### Updateable End ####");
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo3_Insertable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo3_Insertable.cs
new file mode 100644
index 000000000..21bc5f998
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo3_Insertable.cs
@@ -0,0 +1,75 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo3_Insertable
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Insertable Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+ var insertObj = new Order() { Id = 1, Name = "order1",Price=0 };
+ var updateObjs = new List {
+ new Order() { Id = 11, Name = "order11", Price=0 },
+ new Order() { Id = 12, Name = "order12" , Price=0}
+ };
+ var x = db.Insertable(updateObjs).RemoveDataCache().IgnoreColumns(it => it.CreateTime).UseParameter().ExecuteCommand();
+ //Ignore CreateTime
+ db.Insertable(insertObj).IgnoreColumns(it => new { it.CreateTime }).ExecuteReturnIdentity();//get identity
+ db.Insertable(insertObj).IgnoreColumns("CreateTime").ExecuteReturnIdentity();
+
+ //Only insert Name and Price
+ db.Insertable(insertObj).InsertColumns(it => new { it.Name, it.Price }).ExecuteReturnIdentity();
+ db.Insertable(insertObj).InsertColumns("Name", "Price").ExecuteReturnIdentity();
+
+ //ignore null columns
+ db.Insertable(updateObjs).ExecuteCommand();//get change row count
+
+ //Use Lock
+ db.Insertable(insertObj).With(SqlWith.UpdLock).ExecuteCommand();
+
+ db.Deleteable().ExecuteCommand();
+ db.Insertable(new Order()
+ {
+ CreateTime = DateTime.Now,
+ CustomId = 11,
+ Name = "11",
+ Price = 11
+ }).UseMySql().ExecuteBulkCopy();
+ db.Insertable(new OrderItem()
+ {
+ CreateTime = DateTime.Now,
+ ItemId = 1,
+ OrderId = 1,
+ OrderName = "a",
+ Price = 11
+ }).UseMySql().ExecuteBulkCopy();
+ var data = db.Queryable().ToList();
+ db.Insertable(data).UseMySql().ExecuteBulkCopy();
+ db.Fastest().BulkUpdate(data);
+ Console.WriteLine("#### Insertable End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo4_Deleteable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo4_Deleteable.cs
new file mode 100644
index 000000000..f5d885375
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo4_Deleteable.cs
@@ -0,0 +1,48 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo4_Deleteable
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Deleteable Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ //by entity
+ db.Deleteable().Where(new Order() { Id = 1111 }).ExecuteCommand();
+
+ //by primary key
+ db.Deleteable().In(1111).ExecuteCommand();
+
+ //by primary key array
+ db.Deleteable().In(new int[] { 1111, 2222 }).ExecuteCommand();
+
+ //by expression
+ db.Deleteable().Where(it => it.Id == 11111).ExecuteCommand();
+
+ Console.WriteLine("#### Deleteable End ####");
+
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo5_SqlQueryable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo5_SqlQueryable.cs
new file mode 100644
index 000000000..f350c18aa
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo5_SqlQueryable.cs
@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo5_SqlQueryable
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### SqlQueryable Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true
+ });
+
+ int total = 0;
+ var list = db.SqlQueryable("select * from `order`").ToPageList(1, 2, ref total);
+
+
+ //by expression
+ var list2 = db.SqlQueryable("select * from `order`").Where(it => it.Id == 1).ToPageList(1, 2);
+ //by sql
+ var list3 = db.SqlQueryable("select * from `order`").Where("id=@id", new { id = 1 }).ToPageList(1, 2);
+
+ Console.WriteLine("#### SqlQueryable End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo6_Queue.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo6_Queue.cs
new file mode 100644
index 000000000..c283022bc
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo6_Queue.cs
@@ -0,0 +1,52 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo6_Queue
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Queue Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ db.Insertable(new Order() { Name = "a" }).AddQueue();
+ db.Insertable(new Order() { Name = "b" }).AddQueue();
+ db.SaveQueues();
+
+
+ db.Insertable(new Order() { Name = "a" }).AddQueue();
+ db.Insertable(new Order() { Name = "b" }).AddQueue();
+ db.Insertable(new Order() { Name = "c" }).AddQueue();
+ db.Insertable(new Order() { Name = "d" }).AddQueue();
+ var ar = db.SaveQueuesAsync();
+ ar.Wait();
+
+ db.Queryable().AddQueue();
+ db.Queryable().AddQueue();
+ db.AddQueue("select * from `order` where id=@id", new { id = 10000 });
+ var result2 = db.SaveQueues();
+
+ Console.WriteLine("#### Queue End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo7_Ado.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo7_Ado.cs
new file mode 100644
index 000000000..c454ce9ff
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo7_Ado.cs
@@ -0,0 +1,59 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo7_Ado
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Ado Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ //sql
+ var dt = db.Ado.GetDataTable("select * from `order` where @id>0 or name=@name", new List(){
+ new SugarParameter("@id",1),
+ new SugarParameter("@name","2")
+ });
+
+ //sql
+ var dt2 = db.Ado.GetDataTable("select * from `order` where @id>0 or name=@name", new { id = 1, name = "2" });
+
+ //Stored Procedure
+ //var dt3 = db.Ado.UseStoredProcedure().GetDataTable("sp_school", new { name = "张三", age = 0 });
+ //var nameP = new SugarParameter("@name", "张三");
+ //var ageP = new SugarParameter("@age", null, true);//isOutput=true
+ //var dt4 = db.Ado.UseStoredProcedure().GetDataTable("sp_school", nameP, ageP);
+
+
+
+ //There are many methods to under db.ado
+ var list= db.Ado.SqlQuery("select * from `order` ");
+ var list2 = db.Ado.SqlQuery("select * from `order` where 1=2;select * from `order` ");
+ var list3 = db.Ado.SqlQuery(" delete from `order` where 2=15 ");
+ var intValue=db.Ado.SqlQuerySingle("select 1");
+ db.Ado.ExecuteCommand("delete from `order` where id>1000");
+ //db.Ado.xxx
+ Console.WriteLine("#### Ado End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo8_Saveable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo8_Saveable.cs
new file mode 100644
index 000000000..61db9a504
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo8_Saveable.cs
@@ -0,0 +1,48 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo8_Saveable
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Saveable Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+
+ //insert or update
+ db.Saveable(new Order() { Id=1, Name="jack" }).ExecuteReturnEntity();
+
+
+ //insert or update
+ db.Saveable(new Order() { Id = 1000, Name = "jack", CreateTime=DateTime.Now })
+ .InsertColumns(it => new { it.Name,it.CreateTime, it.Price})//if insert into name,CreateTime,Price
+ .UpdateColumns(it => new { it.Name, it.CreateTime })//if update set name CreateTime
+ .ExecuteReturnEntity();
+
+ Console.WriteLine("");
+ Console.WriteLine("#### Saveable End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Demo9_EntityMain.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo9_EntityMain.cs
new file mode 100644
index 000000000..ed304e507
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Demo9_EntityMain.cs
@@ -0,0 +1,46 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Demo9_EntityMain
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### EntityMain Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ var entityInfo = db.EntityMaintenance.GetEntityInfo();
+ foreach (var column in entityInfo.Columns)
+ {
+ Console.WriteLine(column.DbColumnName);
+ }
+
+ var dbColumnsName = db.EntityMaintenance.GetDbColumnName("Name");
+
+ var dbTableName = db.EntityMaintenance.GetTableName();
+
+ //more https://github.com/sunkaixuan/SqlSugar/wiki/9.EntityMain
+ Console.WriteLine("#### EntityMain End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoA_DbMain.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoA_DbMain.cs
new file mode 100644
index 000000000..dc2aa20be
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoA_DbMain.cs
@@ -0,0 +1,42 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class DemoA_DbMain
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### DbMain Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+ var tables = db.DbMaintenance.GetTableInfoList();
+ foreach (var table in tables)
+ {
+ Console.WriteLine(table.Description);
+ }
+ //more https://github.com/sunkaixuan/SqlSugar/wiki/a.DbMain
+ Console.WriteLine("#### DbMain End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoB_Aop.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoB_Aop.cs
new file mode 100644
index 000000000..58c183070
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoB_Aop.cs
@@ -0,0 +1,68 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class DemoB_Aop
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Aop Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true
+ });
+ db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event
+ {
+ Console.WriteLine("OnLogExecuted"+sql);
+ };
+ db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution)
+ {
+ Console.WriteLine("OnLogExecuting" + sql);
+ };
+ db.Aop.OnError = (exp) =>//SQL execution error event
+ {
+ //exp.sql
+ };
+ db.Aop.OnExecutingChangeSql = (sql, pars) => //SQL executing event (pre-execution,SQL script can be modified)
+ {
+ return new KeyValuePair(sql, pars);
+ };
+ db.Aop.OnDiffLogEvent = it =>//Get data changes
+ {
+ var editBeforeData = it.BeforeData;
+ var editAfterData = it.AfterData;
+ var sql = it.Sql;
+ var parameter = it.Parameters;
+ var businessData = it.BusinessData;
+ var time = it.Time;
+ var diffType = it.DiffType;//enum insert 、update and delete
+ Console.WriteLine(businessData);
+ Console.WriteLine(editBeforeData[0].Columns[1].Value);
+ Console.WriteLine("to");
+ Console.WriteLine(editAfterData[0].Columns[1].Value);
+ //Write logic
+ };
+
+
+ db.Queryable().ToList();
+ db.Queryable().ToList();
+
+ //OnDiffLogEvent
+ var data = db.Queryable().First();
+ data.Name = "changeName";
+ db.Updateable(data).EnableDiffLogEvent("--update Order--").ExecuteCommand();
+
+ Console.WriteLine("#### Aop End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoD_DbFirst.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoD_DbFirst.cs
new file mode 100644
index 000000000..76528c0d2
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoD_DbFirst.cs
@@ -0,0 +1,75 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ public class DemoD_DbFirst
+ {
+ public static void Init()
+ {
+ Console.WriteLine();
+ Console.WriteLine("#### DbFirst Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true
+ });
+
+ db.DbFirst.CreateClassFile("c:\\Demo\\1", "Models");
+
+
+ db.DbFirst.Where("Student").CreateClassFile("c:\\Demo\\2", "Models");
+
+
+ db.DbFirst.Where(it => it.ToLower().StartsWith("view")).CreateClassFile("c:\\Demo\\3", "Models");
+
+
+ db.DbFirst.Where(it => it.ToLower().StartsWith("view")).CreateClassFile("c:\\Demo\\4", "Models");
+
+
+ db.DbFirst.IsCreateAttribute().CreateClassFile("c:\\Demo\\5", "Models");
+
+
+ db.DbFirst.IsCreateDefaultValue().CreateClassFile("c:\\Demo\\6", "Demo.Models");
+
+
+ db.DbFirst. SettingClassTemplate(old => { return old;})
+ .SettingNamespaceTemplate(old =>{ return old;})
+ .SettingPropertyDescriptionTemplate(old =>
+ {
+ return @" ///
+ /// Desc_New:{PropertyDescription}
+ /// Default_New:{DefaultValue}
+ /// Nullable_New:{IsNullable}
+ /// ";
+ })
+ .SettingPropertyTemplate(old =>{return old;})
+ .SettingConstructorTemplate(old =>{return old; })
+ .CreateClassFile("c:\\Demo\\7");
+
+
+
+ foreach (var item in db.DbMaintenance.GetTableInfoList())
+ {
+ string entityName = item.Name.ToUpper();/*Format class name*/
+ db.MappingTables.Add(entityName , item.Name);
+ foreach (var col in db.DbMaintenance.GetColumnInfosByTableName(item.Name))
+ {
+ db.MappingColumns.Add(col.DbColumnName.ToUpper() /*Format class property name*/, col.DbColumnName, entityName);
+ }
+ }
+ db.DbFirst.IsCreateAttribute().CreateClassFile("c:\\Demo\\8", "Models");
+
+
+ //Use Razor Template
+ //db.DbFirst.UseRazorAnalysis(RazorFirst.DefaultRazorClassTemplate).CreateClassFile("");
+
+ Console.WriteLine("#### DbFirst End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoE_CodeFirst.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoE_CodeFirst.cs
new file mode 100644
index 000000000..f91ce2f36
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoE_CodeFirst.cs
@@ -0,0 +1,40 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ public class DemoE_CodeFirst
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### CodeFirst Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString3,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true
+ });
+ db.DbMaintenance.CreateDatabase();
+ db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
+ db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
+ var list = db.Queryable().ToList();
+ Console.WriteLine("#### CodeFirst end ####");
+ }
+ }
+
+ public class CodeFirstTable1
+ {
+ [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ [SugarColumn(ColumnDataType = "Nvarchar(255)")]//custom
+ public string Text { get; set; }
+ [SugarColumn(IsNullable = true)]
+ public DateTime CreateTime { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoF_Utilities.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoF_Utilities.cs
new file mode 100644
index 000000000..4a83664d9
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoF_Utilities.cs
@@ -0,0 +1,46 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class DemoF_Utilities
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Utilities Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+
+ List ids = Enumerable.Range(1, 100).ToList();
+ db.Utilities.PageEach(ids, 10, list =>
+ {
+ Console.WriteLine(string.Join("," ,list));
+ });
+
+ var list2= db.Utilities.DataTableToList(db.Ado.GetDataTable("select * from `order`"));
+
+ //more https://github.com/sunkaixuan/SqlSugar/wiki/f.Utilities
+ Console.WriteLine("#### Utilities End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoG_SimpleClient.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoG_SimpleClient.cs
new file mode 100644
index 000000000..baac2a296
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoG_SimpleClient.cs
@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class DemoG_SimpleClient
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### SimpleClient Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+ Console.WriteLine("#### SimpleClient End ####");
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoJ_Report.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoJ_Report.cs
new file mode 100644
index 000000000..225b3208b
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoJ_Report.cs
@@ -0,0 +1,142 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class DemoJ_Report
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Utilities Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ Demo1(db);
+ Demo2(db);
+ Demo3(db);
+ }
+
+ private static void Demo1(SqlSugarClient db)
+ {
+ var list = new List() { 1, 2, 3 };
+ var query1 = db.Queryable();
+ var queryable2 = db.Reportable(list).ToQueryable();
+ var x = db.Queryable(queryable2, query1, (x2, x1) => x1.Id.Equals(x2.ColumnName))
+ .Select((x2, x1) => new { x = x1.Id, x2 = x2.ColumnName }).ToList();
+ }
+ private static void Demo2(SqlSugarClient db)
+ {
+ var list = db.Queryable().ToList();
+ var query1 = db.Queryable();
+ var queryable2 = db.Reportable(list).ToQueryable();
+ var x = db.Queryable(query1, queryable2, (x1, x2) => x1.Id.Equals(x2.OrderId))
+ .Select((x1, x2) => new { name = x1.Name,id=x1.Id, orderid = x2.OrderId }).ToList();
+ }
+ private static void Demo3(SqlSugarClient db)
+ {
+ db.CodeFirst.InitTables();
+ db.Deleteable().ExecuteCommand();
+ db.Insertable(new operateinfo()
+ {
+ id=1,
+ operate_type=1,
+ operate_time=Convert.ToDateTime("2021-1-1")
+ }).ExecuteCommand();
+ db.Insertable(new operateinfo()
+ {
+ id = 1,
+ operate_type = 1,
+ operate_time = Convert.ToDateTime("2021-1-2")
+ }).ExecuteCommand();
+ db.Insertable(new operateinfo()
+ {
+ id = 1,
+ operate_type = 1,
+ operate_time = Convert.ToDateTime("2021-3-1")
+ }).ExecuteCommand();
+ db.Insertable(new operateinfo()
+ {
+ id = 1,
+ operate_type = 1,
+ operate_time = Convert.ToDateTime("2021-3-2")
+ }).ExecuteCommand();
+ db.Insertable(new operateinfo()
+ {
+ id = 1,
+ operate_type = 1,
+ operate_time = Convert.ToDateTime("2021-4-2")
+ }).ExecuteCommand();
+
+
+ var queryableLeft = db.Reportable(ReportableDateType.MonthsInLast1years).ToQueryable();
+ var queryableRight = db.Queryable();
+ var list= db.Queryable(queryableLeft, queryableRight, JoinType.Left,
+ (x1, x2) => x2.operate_time.ToString("yyyy-MM")==x1.ColumnName.ToString("yyyy-MM"))
+ .GroupBy((x1,x2)=>x1.ColumnName)
+ .Where(x1=>SqlFunc.Between(x1.ColumnName,"2021-01-01",DateTime.Now))
+ .Select((x1, x2) => new
+ {
+ count=SqlFunc.AggregateSum(SqlFunc.IIF(x2.id>0,1,0)) ,
+ date=x1.ColumnName.ToString("yyyy-MM")
+
+ }).ToList();
+ }
+
+
+ public partial class operateinfo
+ {
+ public operateinfo()
+ {
+
+
+ }
+ ///
+ /// Desc:操作序号
+ /// Default:
+ /// Nullable:False
+ ///
+ public int id { get; set; }
+
+ ///
+ /// Desc:操作时间
+ /// Default:
+ /// Nullable:False
+ ///
+ public DateTime operate_time { get; set; }
+
+ ///
+ /// Desc:操作类型
+ /// Default:
+ /// Nullable:False
+ ///
+ public int operate_type { get; set; }
+
+ ///
+ /// Desc:操作人编号
+ /// Default:
+ /// Nullable:False
+ ///
+ public int user_id { get; set; }
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoN_SplitTable.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoN_SplitTable.cs
new file mode 100644
index 000000000..70964bafa
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoN_SplitTable.cs
@@ -0,0 +1,89 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class DemoN_SplitTable
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### CodeFirst Start ####");
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true
+ });
+ db.Aop.OnLogExecuted = (s, p) =>
+ {
+ Console.WriteLine(s);
+ };
+
+ //初始化分表
+ db.CodeFirst.SplitTables().InitTables();
+
+ Console.WriteLine();
+
+ //根据最近3个表进行查询
+ var list=db.Queryable().Where(it=>it.Pk==Guid.NewGuid())
+ .SplitTable(tabs => tabs.Take(3))
+ .Where(it=>it.Time==DateTime.Now).ToOffsetPage(1,2);
+
+ Console.WriteLine();
+
+ //根据时间选出的表进行查询
+ var list2 = db.Queryable().SplitTable(tabs => tabs.Where(it=> it.Date>=DateTime.Now.AddYears(-2))).ToList();
+
+ Console.WriteLine();
+
+ //删除数据只在最近3张表执行操作
+ var x = db.Deleteable().Where(it=>it.Pk==Guid.NewGuid()).SplitTable(tabs => tabs.Take(3)).ExecuteCommand();
+
+ Console.WriteLine();
+
+ var tableName = db.SplitHelper().GetTableName(DateTime.Now.AddDays(-1));
+ var tableName2 = db.SplitHelper(new OrderSpliteTest() { Time=DateTime.Now}).GetTableNames();
+ var tableName3 = db.SplitHelper(new List {
+ new OrderSpliteTest() { Time = DateTime.Now },
+ new OrderSpliteTest() { Time = DateTime.Now },
+ new OrderSpliteTest() { Time = DateTime.Now.AddMonths(-10) }
+ }).GetTableNames();
+ var x2 = db.Updateable()
+ .SetColumns(it=>it.Name=="a")
+ .Where(it => it.Pk == Guid.NewGuid())
+ .SplitTable(tabs => tabs.InTableNames(tableName2))
+ .ExecuteCommand();
+
+ Console.WriteLine();
+
+ //按日分表
+ var x3 = db.Insertable(new OrderSpliteTest() { Name="A" }).SplitTable().ExecuteCommand();
+
+ Console.WriteLine();
+ ////强制分表类型
+ var x4 = db.Insertable(new OrderSpliteTest() { Name = "A" ,Time=DateTime.Now.AddDays(-1) }).SplitTable().ExecuteCommand();
+
+ var tableName21 = db.SplitHelper().GetTableName(DateTime.Now.AddDays(-111));
+ var listNull = db.Queryable().SplitTable(ta => ta.InTableNames(tableName21)).ToList();
+ Console.WriteLine("#### CodeFirst end ####");
+ }
+
+ [SplitTable(SplitType.Day)]
+ [SqlSugar.SugarTable("Taxxx0101_{year}{month}{day}")]
+ public class OrderSpliteTest
+ {
+ [SugarColumn(IsPrimaryKey =true)]
+ public Guid Pk{ get; set; }
+ public string Name { get; set; }
+ [SugarColumn(IsNullable =true)]
+ [SplitField]
+ public DateTime Time { get; set; }
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/DemoO_Fastest.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoO_Fastest.cs
new file mode 100644
index 000000000..0eba37601
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/DemoO_Fastest.cs
@@ -0,0 +1,60 @@
+using OrmTest;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class TestFAST111
+ {
+
+ public int Sex { get; set; }
+ public DateTime Date { get; set; }
+
+ [SqlSugar.SugarColumn(IsPrimaryKey =true)]
+ public string Id { get; set; }
+ [SqlSugar.SugarColumn(IsNullable = true)]
+ public long X { get; set; }
+ [SqlSugar.SugarColumn(IsNullable = true,IsJson =true,ColumnDataType ="varchar(500)")]
+ public string [] json { get; set; }
+ }
+
+ public class DemoO_Fastest
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Insertable Start ####");
+
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+ db.CodeFirst.InitTables();
+ db.Fastest().BulkCopy(new List() {
+ new TestFAST111(){ Date=DateTime.Now, Id=Guid.NewGuid()+"", Sex=1 , X=111,json=new string[]{ "x"} }
+ });
+ var data = new List() {
+ new TestFAST111(){ Date=DateTime.Now, Id=Guid.NewGuid()+"", Sex=2 , X=112,json=new string[]{ "x"} }
+ };
+ //db.Updateable(data).ExecuteCommand();
+ db.Fastest().BulkUpdate(data);
+ var x = db.Queryable().ToList();
+
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Demo/Democ_GobalFilter.cs b/Src/Asp.Net/MySqlConnectorTest/Demo/Democ_GobalFilter.cs
new file mode 100644
index 000000000..33e6e1413
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Demo/Democ_GobalFilter.cs
@@ -0,0 +1,77 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ public class DemoC_GobalFilter
+ {
+ public static void Init()
+ {
+ Console.WriteLine("");
+ Console.WriteLine("#### Filter Start ####");
+ var db = GetInstance();
+
+
+ var sql = db.Queryable().ToSql();
+ //SELECT [Id],[Name],[Price],[CreateTime] FROM `order` WHERE isDelete=0
+ Console.WriteLine(sql);
+
+
+ var sql2 = db.Queryable((main,ot)=> main.Id==ot.OrderId).ToSql();
+ //SELECT [Id],[Name],[Price],[CreateTime] FROM `order` main ,[OrderDetail] ot WHERE ( [main].[Id] = [ot].[OrderId] ) AND main.isDelete=0
+ Console.WriteLine(sql2);
+
+
+ var sql3 = db.Queryable().Filter("Myfilter").ToSql();// Myfilter+Gobal
+ //SELECT [Id],[Name],[Price],[CreateTime] FROM `order` WHERE Name='jack' AND isDelete=0
+ Console.WriteLine(sql3);
+
+ var sql4 = db.Queryable().Filter("Myfilter",isDisabledGobalFilter:true).ToSql();//only Myfilter
+ //SELECT [Id],[Name],[Price],[CreateTime] FROM `order` WHERE Name='jack'
+ Console.WriteLine(sql4);
+ Console.WriteLine("#### Filter End ####");
+ }
+
+
+ public static SqlSugarClient GetInstance()
+ {
+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { DbType = DbType.MySqlConnector, ConnectionString = Config.ConnectionString, IsAutoCloseConnection = true });
+
+ //single table query gobal filter
+ db.QueryFilter.Add(new SqlFilterItem()
+ {
+ FilterValue = filterDb =>
+ {
+ //Writable logic
+ return new SqlFilterResult() { Sql = " isDelete=0" };//Global string perform best
+ }
+ });
+
+ //Multi-table query gobal filter
+ db.QueryFilter.Add(new SqlFilterItem()
+ {
+ FilterValue = filterDb =>
+ {
+ //Writable logic
+ return new SqlFilterResult() { Sql = " main.isDelete=0" };
+ },
+ IsJoinQuery=true
+ });
+
+ //Specific filters
+ db.QueryFilter.Add(new SqlFilterItem()
+ {
+ FilterName= "Myfilter",
+ FilterValue = filterDb =>
+ {
+ //Writable logic
+ return new SqlFilterResult() { Sql = "Name='jack'" };
+ }
+ });
+ return db;
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/AttributeTable.cs b/Src/Asp.Net/MySqlConnectorTest/Models/AttributeTable.cs
new file mode 100644
index 000000000..c1a43ad12
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/AttributeTable.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ [Table("MyAttributeTable")]
+ //[SugarTable("CustomAttributeTable")]
+ public class AttributeTable
+ {
+
+ [Key]
+ //[SugarColumn(IsPrimaryKey =true)]
+ public string Id { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/CarType.cs b/Src/Asp.Net/MySqlConnectorTest/Models/CarType.cs
new file mode 100644
index 000000000..00dc12710
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/CarType.cs
@@ -0,0 +1,7 @@
+namespace OrmTest
+{
+ public class CarType
+ {
+ public bool State { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Custom.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Custom.cs
new file mode 100644
index 000000000..3b8871c57
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Custom.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Custom
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/EntityMapper.cs b/Src/Asp.Net/MySqlConnectorTest/Models/EntityMapper.cs
new file mode 100644
index 000000000..b597012fb
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/EntityMapper.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+namespace OrmTest
+{
+ [SugarTable("MyEntityMapper")]
+ public class EntityMapper
+ {
+ [SugarColumn(ColumnName ="MyName")]
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Mapper.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Mapper.cs
new file mode 100644
index 000000000..8d7991d6c
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Mapper.cs
@@ -0,0 +1,54 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ [SugarTable("OrderDetail")]
+ public class OrderItemInfo
+ {
+ [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int ItemId { get; set; }
+ public int OrderId { get; set; }
+ public decimal? Price { get; set; }
+ [SqlSugar.SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ [SugarColumn(IsIgnore = true)]
+ public Order Order { get; set; }
+ }
+ [SugarTable("Order")]
+ public class OrderInfo
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ [SugarColumn(IsIgnore = true)]
+ public List Items { get; set; }
+ }
+ public class ABMapping
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int AId { get; set; }
+ public int BId { get; set; }
+ [SugarColumn(IsIgnore = true)]
+ public A A { get; set; }
+ [SugarColumn(IsIgnore = true)]
+ public B B { get; set; }
+
+ }
+ public class A
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+ public class B
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/MyCustomAttributeTable.cs b/Src/Asp.Net/MySqlConnectorTest/Models/MyCustomAttributeTable.cs
new file mode 100644
index 000000000..11359d062
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/MyCustomAttributeTable.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ [Table("CustomAttributeTable")]
+ //[SugarTable("CustomAttributeTable")]
+ public class MyCustomAttributeTable
+ {
+
+ [Key]
+ //[SugarColumn(IsPrimaryKey =true)]
+ public string Id { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Order.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Order.cs
new file mode 100644
index 000000000..d7ff068b8
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Order.cs
@@ -0,0 +1,24 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+
+ public class Order
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+ public decimal Price { get; set; }
+ [SugarColumn(IsNullable = true)]
+ public DateTime CreateTime { get; set; }
+ [SugarColumn(IsNullable =true)]
+ public int CustomId { get; set; }
+ [SugarColumn(IsIgnore = true)]
+ public List Items { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/OrderItem.cs b/Src/Asp.Net/MySqlConnectorTest/Models/OrderItem.cs
new file mode 100644
index 000000000..272e03c74
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/OrderItem.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ [SqlSugar.SugarTable("OrderDetail")]
+ public class OrderItem
+ {
+ [SqlSugar.SugarColumn(IsPrimaryKey =true, IsIdentity =true)]
+ public int ItemId { get; set; }
+ public int OrderId { get; set; }
+ public decimal? Price { get; set; }
+ [SqlSugar.SugarColumn(IsNullable = true)]
+ public DateTime? CreateTime { get; set; }
+ [SqlSugar.SugarColumn(IsIgnore = true)]
+ public string OrderName { get; internal set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/TestTree.cs b/Src/Asp.Net/MySqlConnectorTest/Models/TestTree.cs
new file mode 100644
index 000000000..b8250828a
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/TestTree.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class TestTree
+ {
+ [SqlSugar.SugarColumn(ColumnDataType = "hierarchyid")]
+ public string TreeId { get; set; }
+ [SqlSugar.SugarColumn(ColumnDataType = "Geography")]
+ public string GId { get; set; }
+ public string Name { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Tree.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Tree.cs
new file mode 100644
index 000000000..d2878de64
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Tree.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class Tree
+ {
+ [SqlSugar.SugarColumn(IsPrimaryKey =true)]
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public int ParentId { get; set; }
+ [SqlSugar.SugarColumn(IsIgnore = true)]
+ public Tree Parent { get; set; }
+ [SqlSugar.SugarColumn(IsIgnore = true)]
+ public List Child { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoods.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoods.cs
new file mode 100644
index 000000000..86dcf3488
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoods.cs
@@ -0,0 +1,604 @@
+using SqlSugar;
+
+namespace HONORCSData
+{
+
+ ///
+ /// 商品主表
+ ///
+ [SugarTable("goods")]
+ public class EGoods
+ {
+ ///
+ /// 商品
+ ///
+ public EGoods()
+ {
+ }
+ private int _GoodsId;
+ ///
+ /// 商品id
+ ///
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_id")]
+ public int GoodsId { get => _GoodsId; set => _GoodsId = value; }
+ private string _GoodsNo;
+ ///
+ /// 商品编号
+ ///
+ [SugarColumn( ColumnName = "goods_no")]
+ public string GoodsNo { get => _GoodsNo; set => _GoodsNo = value?.Trim(); }
+
+ private string _BarCode;
+ ///
+ /// 条码
+ ///
+ [SugarColumn(ColumnName = "bar_code")]
+ public string BarCode { get => _BarCode; set => _BarCode = value?.Trim(); }
+
+ private string _Description;
+ ///
+ /// 描述
+ ///
+ [SugarColumn(ColumnName = "description")]
+ public string Description { get => _Description; set => _Description = value?.Trim(); }
+
+ private decimal _RetailPrice;
+ ///
+ /// 零售价
+ ///
+ [SugarColumn(ColumnName = "retail_price")]
+ public decimal RetailPrice { get => _RetailPrice; set => _RetailPrice = value; }
+
+ private decimal _DeliveryPrice;
+ ///
+ /// 送货价
+ ///
+ [SugarColumn(ColumnName = "delivery_price")]
+ public decimal DeliveryPrice { get => _DeliveryPrice; set => _DeliveryPrice = value; }
+
+ private decimal _MemberPrice;
+ ///
+ /// 会员价
+ ///
+ [SugarColumn(ColumnName = "member_price")]
+ public decimal MemberPrice { get => _MemberPrice; set => _MemberPrice = value; }
+
+ private decimal _WholesalePrice;
+ ///
+ /// 批发价
+ ///
+ [SugarColumn(ColumnName = "wholesale_price")]
+ public decimal WholesalePrice { get => _WholesalePrice; set => _WholesalePrice = value; }
+
+ private decimal _ReceiptPrice;
+ ///
+ /// 发票价
+ ///
+ [SugarColumn(ColumnName = "receipt_price")]
+ public decimal ReceiptPrice { get => _ReceiptPrice; set => _ReceiptPrice = value; }
+
+ private decimal _InternetPrice;
+ ///
+ /// 网络价
+ ///
+ [SugarColumn(ColumnName = "internet_price")]
+ public decimal InternetPrice { get => _InternetPrice; set => _InternetPrice = value; }
+
+ private decimal _FriendshipPrice;
+ ///
+ /// 友情价
+ ///
+ [SugarColumn(ColumnName = "friendship_price")]
+ public decimal FriendshipPrice { get => _FriendshipPrice; set => _FriendshipPrice = value; }
+
+ private decimal _SpecialPrice;
+ ///
+ /// 特别价
+ ///
+ [SugarColumn(ColumnName = "special_price")]
+ public decimal SpecialPrice { get => _SpecialPrice; set => _SpecialPrice = value; }
+
+ private decimal _PromotionPrice;
+ ///
+ /// 促销价
+ ///
+ [SugarColumn(ColumnName = "promotion_price")]
+ public decimal PromotionPrice { get => _PromotionPrice; set => _PromotionPrice = value; }
+
+ private decimal _PurchasePrice;
+ ///
+ /// 进货价
+ ///
+ [SugarColumn(ColumnName = "purchase_price")]
+ public decimal PurchasePrice { get => _PurchasePrice; set => _PurchasePrice = value; }
+
+ private string _SpanishName;
+ ///
+ /// 西文名称
+ ///
+ [SugarColumn(ColumnName = "spanish_name")]
+ public string SpanishName { get => _SpanishName; set => _SpanishName = value?.Trim(); }
+
+ private string _Initials;
+ ///
+ /// 首字母
+ ///
+ [SugarColumn(ColumnName = "initials")]
+ public string Initials { get => _Initials; set => _Initials = value?.Trim(); }
+
+ private string _ChineseName;
+ ///
+ /// 中文名称
+ ///
+ [SugarColumn(ColumnName = "chinese_name")]
+ public string ChineseName { get => _ChineseName; set => _ChineseName = value?.Trim(); }
+
+ ///
+ /// 商品名称 西文中文组合
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string GoodsName { get => string.Format("{0}[{1}]", _SpanishName, _ChineseName); }
+
+ private string _ChinesePinyin;
+ ///
+ /// 拼音
+ ///
+ [SugarColumn(ColumnName = "chinese_pinyin")]
+ public string ChinesePinyin { get => _ChinesePinyin; set => _ChinesePinyin = value?.Trim(); }
+
+ private decimal _PackageNumber;
+ ///
+ /// 整包数量
+ ///
+ [SugarColumn(ColumnName = "package_number")]
+ public decimal PackageNumber { get => _PackageNumber; set => _PackageNumber = value; }
+
+ private decimal _BoxNumber;
+ ///
+ /// 整箱数量
+ ///
+ [SugarColumn(ColumnName = "box_number")]
+ public decimal BoxNumber { get => _BoxNumber; set => _BoxNumber = value; }
+
+ private double _WeightCapacity;
+ ///
+ /// 重量容量
+ ///
+ [SugarColumn(ColumnName = "weight_capacity")]
+ public double WeightCapacity { get => _WeightCapacity; set => _WeightCapacity = value; }
+
+ private bool _IsOnlyPerUnit;
+ ///
+ /// 是否只按单位
+ ///
+ [SugarColumn(ColumnName = "is_only_per_unit")]
+ public bool IsOnlyPerUnit { get => _IsOnlyPerUnit; set => _IsOnlyPerUnit = value; }
+
+ private int _GoodsClassId;
+ ///
+ /// 商品类别编号
+ ///
+ [SugarColumn(ColumnName = "goods_class_id")]
+ public int GoodsClassId { get => _GoodsClassId; set => _GoodsClassId = value; }
+
+ ///
+ /// 商品类别名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string GoodsClass { get; set; }
+
+ private string _UnitName;
+ ///
+ /// 单位名称
+ ///
+ [SugarColumn(ColumnName = "unit_name")]
+ public string UnitName { get => _UnitName; set => _UnitName = value?.Trim(); }
+
+ private System.DateTime? _GoodsAddDate;
+ ///
+ /// 商品添加日期
+ ///
+ [SugarColumn(ColumnName = "goods_add_date")]
+ public System.DateTime? GoodsAddDate { get => _GoodsAddDate; set => _GoodsAddDate = value ?? default(System.DateTime); }
+
+ private decimal _Discount;
+ ///
+ /// 折扣
+ ///
+ [SugarColumn(ColumnName = "discount")]
+ public decimal Discount { get => _Discount; set => _Discount = value; }
+
+ private decimal _DiscountPrice;
+ ///
+ /// 折扣价
+ ///
+ [SugarColumn(ColumnName = "discount_price")]
+ public decimal DiscountPrice { get => _DiscountPrice; set => _DiscountPrice = value; }
+
+ private decimal _ReceiptPercentage;
+ ///
+ /// 发票百分比
+ ///
+ [SugarColumn(ColumnName = "receipt_percentage")]
+ public decimal ReceiptPercentage { get => _ReceiptPercentage; set => _ReceiptPercentage = value; }
+
+ private System.DateTime? _ExpiryDate;
+ ///
+ /// 到期日期
+ ///
+ [SugarColumn(ColumnName = "expiry_date")]
+ public System.DateTime? ExpiryDate { get => _ExpiryDate; set => _ExpiryDate = value ?? default(System.DateTime); }
+
+ private string _SupplierId;
+ ///
+ /// 供应商编号
+ ///
+ [SugarColumn(ColumnName = "supplier_id")]
+ public string SupplierId { get => _SupplierId; set => _SupplierId = value?.Trim(); }
+
+ private int _IsGift;
+ ///
+ /// 是否有赠品
+ ///
+ [SugarColumn(ColumnName = "is_gift")]
+ public int IsGift { get => _IsGift; set => _IsGift = value; }
+
+ private int _IsPrivate;
+ ///
+ /// 是否私营
+ ///
+ [SugarColumn(ColumnName = "is_private")]
+ public int IsPrivate { get => _IsPrivate; set => _IsPrivate = value; }
+
+ private System.Boolean? _IsPriceByVolume;
+ ///
+ /// 是否以量定价
+ ///
+ [SugarColumn(ColumnName = "is_price_by_volume")]
+ public System.Boolean? IsPriceByVolume { get { return this._IsPriceByVolume; } set { this._IsPriceByVolume = value ?? default(System.Boolean); } }
+
+ private System.Boolean? _IsDiscountByQuantity;
+ ///
+ /// 是否以量定折扣
+ ///
+ [SugarColumn(ColumnName = "is_discount_by_quantity")]
+ public System.Boolean? IsDiscountByQuantity { get { return this._IsDiscountByQuantity; } set { this._IsDiscountByQuantity = value ?? default(System.Boolean); } }
+
+ private decimal _Price1;
+ ///
+ /// 价格1
+ ///
+ [SugarColumn(ColumnName = "price1")]
+ public decimal Price1 { get => _Price1; set => _Price1 = value; }
+
+ private decimal _Discount1;
+ ///
+ /// 折扣1
+ ///
+ [SugarColumn(ColumnName = "discount1")]
+ public decimal Discount1 { get => _Discount1; set => _Discount1 = value; }
+
+ private decimal _Number1;
+ ///
+ /// 数量1
+ ///
+ [SugarColumn(ColumnName = "number1")]
+ public decimal Number1 { get => _Number1; set => _Number1 = value; }
+
+ private decimal _Price2;
+ ///
+ /// 价格2
+ ///
+ [SugarColumn(ColumnName = "price2")]
+ public decimal Price2 { get => _Price2; set => _Price2 = value; }
+
+ private decimal _Discount2;
+ ///
+ /// 折扣2
+ ///
+ [SugarColumn(ColumnName = "discount2")]
+ public decimal Discount2 { get => _Discount2; set => _Discount2 = value; }
+
+ private decimal _Number2;
+ ///
+ /// 数量2
+ ///
+ [SugarColumn(ColumnName = "number2")]
+ public decimal Number2 { get => _Number2; set => _Number2 = value; }
+
+ private decimal _Price3;
+ ///
+ /// 价格3
+ ///
+ [SugarColumn(ColumnName = "price3")]
+ public decimal Price3 { get => _Price3; set => _Price3 = value; }
+
+ private decimal _Discount3;
+ ///
+ /// 折扣3
+ ///
+ [SugarColumn(ColumnName = "discount3")]
+ public decimal Discount3 { get => _Discount3; set => _Discount3 = value; }
+
+ private decimal _Number3;
+ ///
+ /// 数量3
+ ///
+ [SugarColumn(ColumnName = "number3")]
+ public decimal Number3 { get => _Number3; set => _Number3 = value; }
+
+ private decimal _Price4;
+ ///
+ /// 价格4
+ ///
+ [SugarColumn(ColumnName = "price4")]
+ public decimal Price4 { get => _Price4; set => _Price4 = value; }
+
+ private decimal _Discount4;
+ ///
+ /// 折扣4
+ ///
+ [SugarColumn(ColumnName = "discount4")]
+ public decimal Discount4 { get => _Discount4; set => _Discount4 = value; }
+
+ private decimal _Number4;
+ ///
+ /// 数量4
+ ///
+ [SugarColumn(ColumnName = "number4")]
+ public decimal Number4 { get => _Number4; set => _Number4 = value; }
+
+ private decimal _Price5;
+ ///
+ /// 价格5
+ ///
+ [SugarColumn(ColumnName = "price5")]
+ public decimal Price5 { get => _Price5; set => _Price5 = value; }
+
+ private decimal _Discount5;
+ ///
+ /// 折扣5
+ ///
+ [SugarColumn(ColumnName = "discount5")]
+ public decimal Discount5 { get => _Discount5; set => _Discount5 = value; }
+
+ private decimal _Number5;
+ ///
+ /// 数量5
+ ///
+ [SugarColumn(ColumnName = "number5")]
+ public decimal Number5 { get => _Number5; set => _Number5 = value; }
+
+ private decimal _Price6;
+ ///
+ /// 价格6
+ ///
+ [SugarColumn(ColumnName = "price6")]
+ public decimal Price6 { get => _Price6; set => _Price6 = value; }
+
+ private decimal _Discount6;
+ ///
+ /// 折扣6
+ ///
+ [SugarColumn(ColumnName = "discount6")]
+ public decimal Discount6 { get => _Discount6; set => _Discount6 = value; }
+
+ private string _WarehouseSite;
+ ///
+ /// 仓库位置
+ ///
+ [SugarColumn(ColumnName = "warehouse_site")]
+ public string WarehouseSite { get => _WarehouseSite; set => _WarehouseSite = value?.Trim(); }
+
+ private string _GoodsGrade;
+ ///
+ /// 商品等级
+ ///
+ [SugarColumn(ColumnName = "goods_grade")]
+ public string GoodsGrade { get => _GoodsGrade; set => _GoodsGrade = value?.Trim(); }
+
+ private decimal _MinStock;
+ ///
+ /// 库存下限
+ ///
+ [SugarColumn(ColumnName = "min_stock")]
+ public decimal MinStock { get => _MinStock; set => _MinStock = value; }
+
+ private decimal _MaxStock;
+ ///
+ /// 库存上限
+ ///
+ [SugarColumn(ColumnName = "max_stock")]
+ public decimal MaxStock { get => _MaxStock; set => _MaxStock = value; }
+
+ private bool _IsContainImage;
+ ///
+ /// 有图案
+ ///
+ [SugarColumn(ColumnName = "is_contain_image")]
+ public bool IsContainImage { get => _IsContainImage; set => _IsContainImage = value; }
+
+ private string _GoodsImageMd5;
+ ///
+ /// 图案的消息摘要
+ ///
+ [SugarColumn(ColumnName = "goods_image_md5")]
+ public string GoodsImageMd5 { get => _GoodsImageMd5; set => _GoodsImageMd5 = value?.Trim(); }
+
+ private System.DateTime? _ImageUpdateTime;
+ ///
+ /// 修改绘图时间
+ ///
+ [SugarColumn(ColumnName = "image_update_time")]
+ public System.DateTime? ImageUpdateTime { get => _ImageUpdateTime; set => _ImageUpdateTime = value ?? default(System.DateTime); }
+ //private Goods.EGoodsImage _GoodsImage = new Goods.EGoodsImage();
+ /////
+ ///// 图片
+ /////
+ //[SugarColumn(IsIgnore = true)]
+ //public Goods.EGoodsImage GoodsImage { get=>_GoodsImage; set => _GoodsImage = value; }
+
+ private bool _IsProhibitedChangeDiscount;
+ ///
+ /// 是否禁止更改折扣
+ ///
+ [SugarColumn(ColumnName = "is_prohibited_change_discount")]
+ public bool IsProhibitedChangeDiscount { get => _IsProhibitedChangeDiscount; set => _IsProhibitedChangeDiscount = value; }
+
+ private bool _PrintSign;
+ ///
+ /// 打印标记
+ ///
+ [SugarColumn(ColumnName = "print_sign")]
+ public bool PrintSign { get => _PrintSign; set => _PrintSign = value; }
+
+ private System.DateTime? _PrintSignTime;
+ ///
+ /// 打印标记时间
+ ///
+ [SugarColumn(ColumnName = "print_sign_time")]
+ public System.DateTime? PrintSignTime { get => _PrintSignTime; set => _PrintSignTime = value ?? default(System.DateTime); }
+
+ private bool _IsAddByAttachment;
+ ///
+ /// 是否添加为附件
+ ///
+ [SugarColumn(ColumnName = "is_add_by_attachment")]
+ public bool IsAddByAttachment { get => _IsAddByAttachment; set => _IsAddByAttachment = value; }
+
+ private string _MultipleBarcode;
+ ///
+ /// 多条码
+ ///
+ [SugarColumn(ColumnName = "multiple_barcode")]
+ public string MultipleBarcode { get => _MultipleBarcode; set => _MultipleBarcode = value?.Trim(); }
+
+ private string _PartialConsultation;
+ ///
+ /// 部分查询
+ ///
+ [SugarColumn(ColumnName = "partial_consultation")]
+ public string PartialConsultation { get => _PartialConsultation; set => _PartialConsultation = value?.Trim(); }
+
+ private System.DateTime? _StartDate;
+ ///
+ /// 起始日期
+ ///
+ [SugarColumn(ColumnName = "start_date")]
+ public System.DateTime? StartDate { get => _StartDate; set => _StartDate = value ?? default(System.DateTime); }
+
+ private int _IsLock;
+ ///
+ /// 是否锁定:1 锁定(下架) 0 未锁定(在售)
+ ///
+ [SugarColumn(ColumnName = "is_lock")]
+ public int IsLock { get => _IsLock; set => _IsLock = value; }
+
+ private int _SpecialSign;
+ ///
+ /// 特殊标识
+ ///
+ [SugarColumn(ColumnName = "special_sign")]
+ public int SpecialSign { get => _SpecialSign; set => _SpecialSign = value; }
+
+ private string _Remark;
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public string Remark { get => _Remark; set => _Remark = value?.Trim(); }
+
+ private string _DelFlag = "0";
+ ///
+ /// 删除标记:1 删除 0 非删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public string DelFlag { get => _DelFlag; set => _DelFlag = value?.Trim(); }
+
+ private int? _BrandId;
+ ///
+ /// 商品品牌id
+ ///
+ [SugarColumn(ColumnName = "brand_id")]
+ public int? BrandId { get => _BrandId; set => _BrandId = value ?? default(int); }
+
+ ///
+ /// 商品品牌名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string Brand { get; set; }
+
+ private string _Origin;
+ ///
+ /// 产地
+ ///
+ [SugarColumn(ColumnName = "origin")]
+ public string Origin { get => _Origin; set => _Origin = value?.Trim(); }
+
+ private string _ValuationMethod;
+ ///
+ /// 计价方式:1 包装 2 称重
+ ///
+ [SugarColumn(ColumnName = "valuation_method")]
+ public string ValuationMethod { get => _ValuationMethod; set => _ValuationMethod = value?.Trim(); }
+
+ private string _SyncOnlineShop;
+ ///
+ /// 是否同步网店:1 同步 0 不同步
+ ///
+ [SugarColumn(ColumnName = "sync_online_shop")]
+ public string SyncOnlineShop { get => _SyncOnlineShop; set => _SyncOnlineShop = value?.Trim(); }
+
+ private string _PackageSale;
+ ///
+ /// 是否整包销售:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "package_sale")]
+ public string PackageSale { get => _PackageSale; set => _PackageSale = value?.Trim(); }
+
+ private string _IsEnablePoints;
+ ///
+ /// 是否启用积分:1 启用 0 不启用
+ ///
+ [SugarColumn(ColumnName = "is_enable_points")]
+ public string IsEnablePoints { get => _IsEnablePoints; set => _IsEnablePoints = value?.Trim(); }
+
+ private string _PointsRule;
+ ///
+ /// 积分规则
+ ///
+ [SugarColumn(ColumnName = "points_rule")]
+ public string PointsRule { get => _PointsRule; set => _PointsRule = value?.Trim(); }
+
+ private string _PurchaseSpec;
+ ///
+ /// 进货规格
+ ///
+ [SugarColumn(ColumnName = "purchase_spec")]
+ public string PurchaseSpec { get => _PurchaseSpec; set => _PurchaseSpec = value?.Trim(); }
+
+ private System.Boolean? _IsIntervalPrice;
+ ///
+ /// 是否启用区间价格:1 启用 0 不启用
+ ///
+ [SugarColumn(ColumnName = "is_interval_price")]
+ public System.Boolean? IsIntervalPrice { get { return this._IsIntervalPrice; } set { this._IsIntervalPrice = value ?? default(System.Boolean); } }
+
+ private System.Boolean? _IsCountEarning;
+ ///
+ /// 是否计算利润(毛利润):1 启用 0 不启用
+ ///
+ [SugarColumn(ColumnName = "is_count_earning")]
+ public System.Boolean? IsCountEarning { get { return this._IsCountEarning; } set { this._IsCountEarning = value ?? default(System.Boolean); } }
+
+ private int _TenantId;
+ ///
+ /// 所属租户
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public int TenantId { get => _TenantId; set => _TenantId = value; }
+
+ [SugarColumn(IsIgnore = true)]
+ public decimal StockNum { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsBrand.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsBrand.cs
new file mode 100644
index 000000000..0965b6e92
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsBrand.cs
@@ -0,0 +1,68 @@
+using SqlSugar;
+
+namespace HONORCSData
+{
+ ///
+ /// 商品品牌
+ ///
+ [SugarTable("goods_brand")]
+ public class EGoodsBrand
+ {
+ ///
+ ///
+ ///
+ public EGoodsBrand()
+ {
+ }
+
+ private System.Int32 _BrandId;
+ ///
+ /// 自增编号
+ ///
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "brand_id")]
+ public System.Int32 BrandId { get { return this._BrandId; } set { this._BrandId = value; } }
+
+ private System.String _BrandCnName;
+ ///
+ /// 中文名称
+ ///
+ [SugarColumn(ColumnName = "brand_cn_name")]
+ public System.String BrandCnName { get { return this._BrandCnName; } set { this._BrandCnName = value?.Trim(); } }
+
+ private System.String _BranchSpanishName;
+ ///
+ /// 西文名称
+ ///
+ [SugarColumn(ColumnName = "branch_spanish_name")]
+ public System.String BranchSpanishName { get { return this._BranchSpanishName; } set { this._BranchSpanishName = value?.Trim(); } }
+
+
+ private System.String _BrandNo;
+ ///
+ /// 编号
+ ///
+ [SugarColumn(ColumnName = "brand_no")]
+ public System.String BrandNo { get { return this._BrandNo; } set { this._BrandNo = value?.Trim(); } }
+
+ private System.String _BrandStatus = "1";
+ ///
+ /// 状态:1 正常 0 禁用
+ ///
+ [SugarColumn(ColumnName = "brand_status")]
+ public System.String BrandStatus { get { return this._BrandStatus; } set { this._BrandStatus = value?.Trim(); } }
+
+ private System.String _DelFlag = "0";
+ ///
+ /// 是否删除:1 删除 0 未删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public System.String DelFlag { get { return this._DelFlag; } set { this._DelFlag = value?.Trim(); } }
+
+ private int _TenantId;
+ ///
+ /// 所属租户
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public int TenantId { get => _TenantId; set => _TenantId = value; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsClass.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsClass.cs
new file mode 100644
index 000000000..5d0652ee2
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EGoodsClass.cs
@@ -0,0 +1,261 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HONORCSData.Goods
+{
+ ///
+ /// 商品种类
+ ///
+ [SugarTable("goods_class")]
+ public class EGoodsClass
+ {
+ private System.Int32 _GoodsClassId;
+ ///
+ /// 商品种类编号
+ ///
+ [SugarColumn(IsPrimaryKey = true,ColumnName = "goods_class_id")]
+ public System.Int32 GoodsClassId { get { return this._GoodsClassId; } set { this._GoodsClassId = value; } }
+
+ private System.String _SpanishName;
+ ///
+ /// 西文名称
+ ///
+ [SugarColumn(ColumnName = "spanish_name")]
+ public System.String SpanishName { get { return this._SpanishName; } set { this._SpanishName = value?.Trim(); } }
+
+ private System.String _ChineseName;
+ ///
+ /// 中文名称
+ ///
+ [SugarColumn(ColumnName = "chinese_name")]
+ public System.String ChineseName { get { return this._ChineseName; } set { this._ChineseName = value?.Trim(); } }
+
+ private System.Int16 _IvaId;
+ ///
+ /// iva编号
+ ///
+ [SugarColumn(ColumnName = "iva_id")]
+ public System.Int16 IvaId { get { return this._IvaId; } set { this._IvaId = value; } }
+
+
+ private System.String _GoodsClassNo;
+ ///
+ /// 编号
+ ///
+ [SugarColumn(ColumnName = "goods_class_no")]
+ public System.String GoodsClassNo { get { return this._GoodsClassNo; } set { this._GoodsClassNo = value?.Trim(); } }
+
+ private System.Decimal _Discount;
+ ///
+ /// 折扣
+ ///
+ [SugarColumn(ColumnName = "discount")]
+ public System.Decimal Discount { get { return this._Discount; } set { this._Discount = value; } }
+
+ private System.Decimal _ReceiptPercentage;
+ ///
+ /// 发票百分比
+ ///
+ [SugarColumn(ColumnName = "receipt_percentage")]
+ public System.Decimal ReceiptPercentage { get { return this._ReceiptPercentage; } set { this._ReceiptPercentage = value; } }
+
+ private System.Boolean _IsOnlyPerUnit;
+ ///
+ /// 是否仅每单位
+ ///
+ [SugarColumn(ColumnName = "is_only_per_unit")]
+ public System.Boolean IsOnlyPerUnit { get { return this._IsOnlyPerUnit; } set { this._IsOnlyPerUnit = value; } }
+
+ private System.String _UnitName;
+ ///
+ /// 单位名称
+ ///
+ [SugarColumn(ColumnName = "unit_name")]
+ public System.String UnitName { get { return this._UnitName; } set { this._UnitName = value?.Trim(); } }
+
+ private System.Boolean _IsCountEarning;
+ ///
+ /// 是否计算收益
+ ///
+ [SugarColumn(ColumnName = "is_count_earning")]
+ public System.Boolean IsCountEarning { get { return this._IsCountEarning; } set { this._IsCountEarning = value; } }
+
+ private System.Boolean _IsCountStock;
+ ///
+ /// 是否计算库存
+ ///
+ [SugarColumn(ColumnName = "is_count_stock")]
+ public System.Boolean IsCountStock { get { return this._IsCountStock; } set { this._IsCountStock = value; } }
+
+ private System.Boolean _IsProhibitedChangeDiscount;
+ ///
+ /// 是否禁止更改折扣
+ ///
+ [SugarColumn(ColumnName = "is_prohibited_change_discount")]
+ public System.Boolean IsProhibitedChangeDiscount { get { return this._IsProhibitedChangeDiscount; } set { this._IsProhibitedChangeDiscount = value; } }
+
+ private System.Boolean _IsGift;
+ ///
+ /// 是否为赠品
+ ///
+ [SugarColumn(ColumnName = "is_gift")]
+ public System.Boolean IsGift { get { return this._IsGift; } set { this._IsGift = value; } }
+
+ private System.Boolean _IsPrivate;
+ ///
+ /// 是否私营
+ ///
+ [SugarColumn(ColumnName = "is_private")]
+ public System.Boolean IsPrivate { get { return this._IsPrivate; } set { this._IsPrivate = value; } }
+
+ private System.Int16 _GoodsStorehouse;
+ ///
+ /// 商品仓库
+ ///
+ [SugarColumn(ColumnName = "goods_storehouse")]
+ public System.Int16 GoodsStorehouse { get { return this._GoodsStorehouse; } set { this._GoodsStorehouse = value; } }
+
+ private System.Decimal _RetailPriceProfitPercentage;
+ ///
+ /// 零售价利润百分比
+ ///
+ [SugarColumn(ColumnName = "retail_price_profit_percentage")]
+ public System.Decimal RetailPriceProfitPercentage { get { return this._RetailPriceProfitPercentage; } set { this._RetailPriceProfitPercentage = value; } }
+
+ private System.Decimal _DeliveryPriceProfitPercentage;
+ ///
+ /// 送货价收益百分比
+ ///
+ [SugarColumn(ColumnName = "delivery_price_profit_percentage")]
+ public System.Decimal DeliveryPriceProfitPercentage { get { return this._DeliveryPriceProfitPercentage; } set { this._DeliveryPriceProfitPercentage = value; } }
+
+ private System.Decimal _MemberPriceProfitPercentage;
+ ///
+ /// 会员价百分比
+ ///
+ [SugarColumn(ColumnName = "member_price_profit_percentage")]
+ public System.Decimal MemberPriceProfitPercentage { get { return this._MemberPriceProfitPercentage; } set { this._MemberPriceProfitPercentage = value; } }
+
+ private System.Decimal _WholesalePriceProfitPercentage;
+ ///
+ /// 批发价收益百分比
+ ///
+ [SugarColumn(ColumnName = "wholesale_price_profit_percentage")]
+ public System.Decimal WholesalePriceProfitPercentage { get { return this._WholesalePriceProfitPercentage; } set { this._WholesalePriceProfitPercentage = value; } }
+
+ private System.Decimal _ReceiptPriceProfitPercentage;
+ ///
+ /// 发票价格收益百分比
+ ///
+ [SugarColumn(ColumnName = "receipt_price_profit_percentage")]
+ public System.Decimal ReceiptPriceProfitPercentage { get { return this._ReceiptPriceProfitPercentage; } set { this._ReceiptPriceProfitPercentage = value; } }
+
+ private System.Decimal _InternetPriceProfitPercentage;
+ ///
+ /// 网络价格收益百分比
+ ///
+ [SugarColumn(ColumnName = "internet_price_profit_percentage")]
+ public System.Decimal InternetPriceProfitPercentage { get { return this._InternetPriceProfitPercentage; } set { this._InternetPriceProfitPercentage = value; } }
+
+ private System.Decimal _FriendshipPriceProfitPercentage;
+ ///
+ /// 友情价收益百分比
+ ///
+ [SugarColumn(ColumnName = "friendship_price_profit_percentage")]
+ public System.Decimal FriendshipPriceProfitPercentage { get { return this._FriendshipPriceProfitPercentage; } set { this._FriendshipPriceProfitPercentage = value; } }
+
+ private System.Decimal _SpecialPriceProfitPercentage;
+ ///
+ /// 特别价格收益百分比
+ ///
+ [SugarColumn(ColumnName = "special_price_profit_percentage")]
+ public System.Decimal SpecialPriceProfitPercentage { get { return this._SpecialPriceProfitPercentage; } set { this._SpecialPriceProfitPercentage = value; } }
+
+ private System.Decimal _PromotionPriceProfitPercentage;
+ ///
+ /// 促销价格收益百分比
+ ///
+ [SugarColumn(ColumnName = "promotion_price_profit_percentage")]
+ public System.Decimal PromotionPriceProfitPercentage { get { return this._PromotionPriceProfitPercentage; } set { this._PromotionPriceProfitPercentage = value; } }
+
+ private System.Boolean _IsLock;
+ ///
+ /// 是否锁定
+ ///
+ [SugarColumn(ColumnName = "is_lock")]
+ public System.Boolean IsLock { get { return this._IsLock; } set { this._IsLock = value; } }
+
+ private System.String _Remark;
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public System.String Remark { get { return this._Remark; } set { this._Remark = value?.Trim(); } }
+
+ private System.Int32 _ParentId;
+ ///
+ /// 上级分类id
+ ///
+ [SugarColumn(ColumnName = "parent_id")]
+ public System.Int32 ParentId { get { return this._ParentId; } set { this._ParentId = value; } }
+
+ private System.String _IsEnablePoints;
+ ///
+ /// 是否启用积分:1 启用 0 不启用
+ ///
+ [SugarColumn(ColumnName = "is_enable_points")]
+ public System.String IsEnablePoints { get { return this._IsEnablePoints; } set { this._IsEnablePoints = value?.Trim(); } }
+
+ private System.String _PointsRule;
+ ///
+ /// 积分规则
+ ///
+ [SugarColumn(ColumnName = "points_rule")]
+ public System.String PointsRule { get { return this._PointsRule; } set { this._PointsRule = value?.Trim(); } }
+
+ private System.String _ValuationMethod;
+ ///
+ /// 计价方式:1 包装 2 称重
+ ///
+ [SugarColumn(ColumnName = "valuation_method")]
+ public System.String ValuationMethod { get { return this._ValuationMethod; } set { this._ValuationMethod = value?.Trim(); } }
+
+ private System.String _DelFlag;
+ ///
+ /// 删除标记:1 删除 0 未删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public System.String DelFlag { get { return this._DelFlag; } set { this._DelFlag = value?.Trim(); } }
+
+ private System.String _IsShowOnCshier = "1";
+ ///
+ /// 收银前台是否显示:1 显示 0 不显示
+ ///
+ [SugarColumn(ColumnName = "is_show_on_cashier")]
+ public System.String IsShowOnCshier { get { return this._IsShowOnCshier; } set { this._IsShowOnCshier = value?.Trim(); } }
+
+ private System.Int32 _TenantId;
+ ///
+ /// 所属租户
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public System.Int32 TenantId { get { return this._TenantId; } set { this._TenantId = value; } }
+ }
+ public class EGoodsClassTree : EGoodsClass
+ {
+ ///
+ /// 子集
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public List Childrens { get; set; }
+ ///
+ /// 是否选中
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public bool IsSelected { get; set; } = false;
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaran.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaran.cs
new file mode 100644
index 000000000..dccc953a2
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaran.cs
@@ -0,0 +1,404 @@
+using SqlSugar;
+
+namespace HONORCSData.Order
+{
+ ///
+ /// 出库单/入库单
+ ///
+ ///
+ [SugarTable("order_albaran")]
+ public class EOrderAlbaran
+ {
+ ///
+ /// 出库单/入库单
+ ///
+ public EOrderAlbaran()
+ {
+ }
+
+ private System.Int32 _AlbaranId;
+ ///
+ /// 主键id
+ ///
+ [SugarColumn(IsPrimaryKey =true, ColumnName = "albaran_id")]
+ public System.Int32 AlbaranId { get { return this._AlbaranId; } set { this._AlbaranId = value; } }
+
+ private System.Int32? _ServerAccountId;
+ ///
+ /// 服务器端账户id
+ ///
+ [SugarColumn(ColumnName = "server_account_id")]
+ public System.Int32? ServerAccountId { get { return this._ServerAccountId; } set { this._ServerAccountId = value; } }
+
+ private System.String _ClientNo;
+ ///
+ /// 客户/供应商ID
+ ///
+ [SugarColumn(ColumnName = "client_no")]
+ public System.String ClientNo { get { return this._ClientNo; } set { this._ClientNo = value; } }
+
+ private System.Boolean? _IsClientWithoutIva;
+ ///
+ /// 客户是否不含iva:1 含 0 不含
+ ///
+ [SugarColumn(ColumnName = "is_client_without_iva")]
+ public System.Boolean? IsClientWithoutIva { get { return this._IsClientWithoutIva; } set { this._IsClientWithoutIva = value; } }
+
+ private System.Boolean? _IsClientWithoutIvaAndIvaInclude;
+ ///
+ /// ClienteSinIVA的IVAIncluido是否勾选:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_client_without_iva_and_iva_include")]
+ public System.Boolean? IsClientWithoutIvaAndIvaInclude { get { return this._IsClientWithoutIvaAndIvaInclude; } set { this._IsClientWithoutIvaAndIvaInclude = value; } }
+
+ private System.Boolean? _IsClientReq;
+ ///
+ /// 客户是否有REQ:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_client_req")]
+ public System.Boolean? IsClientReq { get { return this._IsClientReq; } set { this._IsClientReq = value; } }
+
+ private System.Boolean? _IsClientReqAndReqInclude;
+ ///
+ /// ClienteREQ的req_include是否勾选:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_client_req_and_req_include")]
+ public System.Boolean? IsClientReqAndReqInclude { get { return this._IsClientReqAndReqInclude; } set { this._IsClientReqAndReqInclude = value; } }
+
+ private System.Decimal? _Discount;
+ ///
+ /// 折扣
+ ///
+ [SugarColumn(ColumnName = "discount")]
+ public System.Decimal? Discount { get { return this._Discount; } set { this._Discount = value; } }
+
+ private System.Decimal? _DirectDiscount;
+ ///
+ /// 直接折扣
+ ///
+ [SugarColumn(ColumnName = "direct_discount")]
+ public System.Decimal? DirectDiscount { get { return this._DirectDiscount; } set { this._DirectDiscount = value; } }
+
+ private System.Int16? _IvaRule;
+ ///
+ /// iva规则(id)
+ ///
+ [SugarColumn(ColumnName = "iva_rule")]
+ public System.Int16? IvaRule { get { return this._IvaRule; } set { this._IvaRule = value; } }
+
+ private System.Int32? _IvaId;
+ ///
+ /// iva_id
+ ///
+ [SugarColumn(ColumnName = "iva_id")]
+ public System.Int32? IvaId { get { return this._IvaId; } set { this._IvaId = value; } }
+
+ private System.Int16? _UsePrice;
+ ///
+ /// 使用价格:1 零售价 2 会员价 3 进货价
+ ///
+ [SugarColumn(ColumnName = "use_price")]
+ public System.Int16? UsePrice { get { return this._UsePrice; } set { this._UsePrice = value; } }
+
+ private System.Decimal? _Total;
+ ///
+ /// 共计
+ ///
+ [SugarColumn(ColumnName = "total")]
+ public System.Decimal? Total { get { return this._Total; } set { this._Total = value; } }
+
+ private System.Decimal? _TotalDiscount;
+ ///
+ /// 折扣总计
+ ///
+ [SugarColumn(ColumnName = "total_discount")]
+ public System.Decimal? TotalDiscount { get { return this._TotalDiscount; } set { this._TotalDiscount = value; } }
+
+ private System.Decimal? _TotalVale;
+ ///
+ /// vale代金券总计
+ ///
+ [SugarColumn(ColumnName = "total_vale")]
+ public System.Decimal? TotalVale { get { return this._TotalVale; } set { this._TotalVale = value; } }
+
+ private System.Decimal? _Profit;
+ ///
+ /// 利润
+ ///
+ [SugarColumn(ColumnName = "profit")]
+ public System.Decimal? Profit { get { return this._Profit; } set { this._Profit = value; } }
+
+ private System.Decimal? _TotalNumber;
+ ///
+ /// 总数量
+ ///
+ [SugarColumn(ColumnName = "total_number")]
+ public System.Decimal? TotalNumber { get { return this._TotalNumber; } set { this._TotalNumber = value; } }
+
+ private System.Decimal? _TotalCash;
+ ///
+ /// 总现金
+ ///
+ [SugarColumn(ColumnName = "total_cash")]
+ public System.Decimal? TotalCash { get { return this._TotalCash; } set { this._TotalCash = value; } }
+
+ private System.DateTime? _AlbaranDate;
+ ///
+ /// albaran日期
+ ///
+ [SugarColumn(ColumnName = "albaran_date")]
+ public System.DateTime? AlbaranDate { get { return this._AlbaranDate; } set { this._AlbaranDate = value; } }
+
+ private System.DateTime? _EntryTime;
+ ///
+ /// 录入时间
+ ///
+ [SugarColumn(ColumnName = "entry_time")]
+ public System.DateTime? EntryTime { get { return this._EntryTime; } set { this._EntryTime = value; } }
+
+ private System.String _OriginDocType;
+ ///
+ /// 原始文件类型
+ ///
+ [SugarColumn(ColumnName = "origin_doc_type")]
+ public System.String OriginDocType { get { return this._OriginDocType; } set { this._OriginDocType = value; } }
+
+ private System.Int32? _OriginDocId;
+ ///
+ /// 原始文件编号
+ ///
+ [SugarColumn(ColumnName = "origin_doc_id")]
+ public System.Int32? OriginDocId { get { return this._OriginDocId; } set { this._OriginDocId = value; } }
+
+ private System.String _DestinationDocType;
+ ///
+ /// 目的文件类型
+ ///
+ [SugarColumn(ColumnName = "destination_doc_type")]
+ public System.String DestinationDocType { get { return this._DestinationDocType; } set { this._DestinationDocType = value; } }
+
+ private System.Int32? _DestinationDocId;
+ ///
+ /// 目的文件编号
+ ///
+ [SugarColumn(ColumnName = "destination_doc_id")]
+ public System.Int32? DestinationDocId { get { return this._DestinationDocId; } set { this._DestinationDocId = value; } }
+
+ private System.Int16? _ChargeType;
+ ///
+ /// 收费类型
+ ///
+ [SugarColumn(ColumnName = "charge_type")]
+ public System.Int16? ChargeType { get { return this._ChargeType; } set { this._ChargeType = value; } }
+
+ private System.Decimal? _Cash;
+ ///
+ /// 收费类型
+ ///
+ [SugarColumn(ColumnName = "cash")]
+ public System.Decimal? Cash { get { return this._Cash; } set { this._Cash = value; } }
+
+ private System.Int32? _AgentId;
+ ///
+ /// 代理商id
+ ///
+ [SugarColumn(ColumnName = "agent_id")]
+ public System.Int32? AgentId { get { return this._AgentId; } set { this._AgentId = value; } }
+
+ private System.Int32? _TransporterId;
+ ///
+ /// 运输商ID
+ ///
+ [SugarColumn(ColumnName = "transporter_id")]
+ public System.Int32? TransporterId { get { return this._TransporterId; } set { this._TransporterId = value; } }
+
+ private System.String _CarNo;
+ ///
+ /// 车牌号
+ ///
+ [SugarColumn(ColumnName = "car_no")]
+ public System.String CarNo { get { return this._CarNo; } set { this._CarNo = value; } }
+
+ private System.Int32? _Operator;
+ ///
+ /// 操作员编号
+ ///
+ [SugarColumn(ColumnName = "operator")]
+ public System.Int32? Operator { get { return this._Operator; } set { this._Operator = value; } }
+
+ private System.Int32? _Verifier;
+ ///
+ /// 审核员编号
+ ///
+ [SugarColumn(ColumnName = "verifier")]
+ public System.Int32? Verifier { get { return this._Verifier; } set { this._Verifier = value; } }
+
+ private System.Int32? _StorehouseId;
+ ///
+ /// 仓库id
+ ///
+ [SugarColumn(ColumnName = "storehouse_id")]
+ public System.Int32? StorehouseId { get { return this._StorehouseId; } set { this._StorehouseId = value; } }
+
+ private System.String _AttachedDocSymbol;
+ ///
+ /// 附加文件符号
+ ///
+ [SugarColumn(ColumnName = "attached_doc_symbol")]
+ public System.String AttachedDocSymbol { get { return this._AttachedDocSymbol; } set { this._AttachedDocSymbol = value; } }
+
+ private System.Int32? _PrePaymentMethod;
+ ///
+ /// 预付款方式
+ ///
+ [SugarColumn(ColumnName = "pre_payment_method")]
+ public System.Int32? PrePaymentMethod { get { return this._PrePaymentMethod; } set { this._PrePaymentMethod = value; } }
+
+ private System.String _ComputerName;
+ ///
+ /// 计算机名称
+ ///
+ [SugarColumn(ColumnName = "computer_name")]
+ public System.String ComputerName { get { return this._ComputerName; } set { this._ComputerName = value; } }
+
+ private System.String _Hash;
+ ///
+ /// 哈希
+ ///
+ [SugarColumn(ColumnName = "hash")]
+ public System.String Hash { get { return this._Hash; } set { this._Hash = value; } }
+
+ private System.Int32? _CifId;
+ ///
+ /// cif_id(到岸编号)
+ ///
+ [SugarColumn(ColumnName = "cif_id")]
+ public System.Int32? CifId { get { return this._CifId; } set { this._CifId = value; } }
+
+ private System.String _SubStoreId;
+ ///
+ /// 子商店编号
+ ///
+ [SugarColumn(ColumnName = "sub_store_id")]
+ public System.String SubStoreId { get { return this._SubStoreId; } set { this._SubStoreId = value; } }
+
+ private System.Decimal? _AbonoTotal;
+ ///
+ /// abono总计
+ ///
+ [SugarColumn(ColumnName = "abono_total")]
+ public System.Decimal? AbonoTotal { get { return this._AbonoTotal; } set { this._AbonoTotal = value; } }
+
+ private System.Decimal? _PaymentTotal;
+ ///
+ /// 付款总计
+ ///
+ [SugarColumn(ColumnName = "payment_total")]
+ public System.Decimal? PaymentTotal { get { return this._PaymentTotal; } set { this._PaymentTotal = value; } }
+
+ private System.Boolean? _IsCharged;
+ ///
+ /// 是否已收款:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_charged")]
+ public System.Boolean? IsCharged { get { return this._IsCharged; } set { this._IsCharged = value; } }
+
+ private System.Boolean? _IsLock;
+ ///
+ /// 是否锁定:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_lock")]
+ public System.Boolean? IsLock { get { return this._IsLock; } set { this._IsLock = value; } }
+
+ private System.Boolean? _IsCanceled;
+ ///
+ /// 是否取消:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_canceled")]
+ public System.Boolean? IsCanceled { get { return this._IsCanceled; } set { this._IsCanceled = value; } }
+
+ private System.String _IsModify;
+ ///
+ /// 是否修改:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_modify")]
+ public System.String IsModify { get { return this._IsModify; } set { this._IsModify = value; } }
+
+ private System.Boolean? _IsSendEmail;
+ ///
+ /// 是否发送电子邮件:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_send_email")]
+ public System.Boolean? IsSendEmail { get { return this._IsSendEmail; } set { this._IsSendEmail = value; } }
+
+ private System.String _Remark;
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public System.String Remark { get { return this._Remark; } set { this._Remark = value; } }
+
+ private System.String _AlbaranNo;
+ ///
+ /// 订单编号
+ ///
+ [SugarColumn(ColumnName = "albaran_no")]
+ public System.String AlbaranNo { get { return this._AlbaranNo; } set { this._AlbaranNo = value; } }
+
+ private System.Int16? _AlbaranType;
+ ///
+ /// 订单类型:1 入库 2 出库
+ ///
+ [SugarColumn(ColumnName = "albaran_type")]
+ public System.Int16? AlbaranType { get { return this._AlbaranType; } set { this._AlbaranType = value; } }
+
+ private System.Int32? _CreateTime;
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(ColumnName = "create_time")]
+ public System.Int32? CreateTime { get { return this._CreateTime; } set { this._CreateTime = value; } }
+
+ private System.Int32? _UpdateTime;
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(ColumnName = "update_time")]
+ public System.Int32? UpdateTime { get { return this._UpdateTime; } set { this._UpdateTime = value; } }
+
+ private System.String _VerifyStatus;
+ ///
+ /// albaran(入库/出库单)审核状态:1 审核 0 未审核
+ ///
+ [SugarColumn(ColumnName = "verify_status")]
+ public System.String VerifyStatus { get { return this._VerifyStatus; } set { this._VerifyStatus = value; } }
+
+ private System.Int32? _VerifyTime;
+ ///
+ /// 审核日期
+ ///
+ [SugarColumn(ColumnName = "verify_time")]
+ public System.Int32? VerifyTime { get { return this._VerifyTime; } set { this._VerifyTime = value; } }
+
+ private System.Int32? _PurchaseReceiveId;
+ ///
+ /// 采购收货订单Id
+ ///
+ [SugarColumn(ColumnName = "purchase_receive_id")]
+ public System.Int32? PurchaseReceiveId { get { return this._PurchaseReceiveId; } set { this._PurchaseReceiveId = value; } }
+
+ private System.String _DelFlag;
+ ///
+ /// 删除标记:1 删除 0 未删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public System.String DelFlag { get { return this._DelFlag; } set { this._DelFlag = value; } }
+
+ private System.Int32 _TenantId;
+ ///
+ /// 所属租户
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public System.Int32 TenantId { get { return this._TenantId; } set { this._TenantId = value; } }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaranDetail.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaranDetail.cs
new file mode 100644
index 000000000..ab5c3730c
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderAlbaranDetail.cs
@@ -0,0 +1,234 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HONORCSData.Order
+{
+ ///
+ /// 出库单/入库单详情
+ ///
+ [SugarTable("order_albaran_detail")]
+ public class EOrderAlbaranDetail
+ {
+ ///
+ /// 出库单/入库单详情
+ ///
+ public EOrderAlbaranDetail()
+ {
+ }
+
+ private System.Int32 _AlbaranId;
+ ///
+ /// albaran_id
+ ///
+ [SugarColumn(ColumnName = "albaran_id")]
+ public System.Int32 AlbaranId { get { return this._AlbaranId; } set { this._AlbaranId = value; } }
+
+ private System.String _GoodsNo;
+ ///
+ /// 商品编号
+ ///
+ [SugarColumn(ColumnName = "goods_no")]
+ public System.String GoodsNo { get { return this._GoodsNo; } set { this._GoodsNo = value; } }
+
+ private System.String _BarCode;
+ ///
+ /// 条码
+ ///
+ [SugarColumn(ColumnName = "bar_code")]
+ public System.String BarCode { get { return this._BarCode; } set { this._BarCode = value; } }
+
+ private System.Boolean _IsBlanceBarCode;
+ ///
+ /// 是否对称条码:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_blance_bar_code")]
+ public System.Boolean IsBlanceBarCode { get { return this._IsBlanceBarCode; } set { this._IsBlanceBarCode = value; } }
+
+ private System.String _SpanishName;
+ ///
+ /// 西文名称
+ ///
+ [SugarColumn(ColumnName = "spanish_name")]
+ public System.String SpanishName { get { return this._SpanishName; } set { this._SpanishName = value; } }
+
+ private System.String _ChineseName;
+ ///
+ /// 中文名称
+ ///
+ [SugarColumn(ColumnName = "chinese_name")]
+ public System.String ChineseName { get { return this._ChineseName; } set { this._ChineseName = value; } }
+
+ private System.Decimal? _Price;
+ ///
+ /// 价格
+ ///
+ [SugarColumn(ColumnName = "price")]
+ public System.Decimal? Price { get { return this._Price; } set { this._Price = value; } }
+
+ private System.Decimal? _Number;
+ ///
+ /// 数量
+ ///
+ [SugarColumn(ColumnName = "number")]
+ public System.Decimal? Number { get { return this._Number; } set { this._Number = value; } }
+
+ private System.Decimal? _Iva;
+ ///
+ /// iva
+ ///
+ [SugarColumn(ColumnName = "iva")]
+ public System.Decimal? Iva { get { return this._Iva; } set { this._Iva = value; } }
+
+ private System.Decimal? _Req;
+ ///
+ /// req
+ ///
+ [SugarColumn(ColumnName = "req")]
+ public System.Decimal? Req { get { return this._Req; } set { this._Req = value; } }
+
+ private System.Int32? _IvaId;
+ ///
+ /// iva_id
+ ///
+ [SugarColumn(ColumnName = "iva_id")]
+ public System.Int32? IvaId { get { return this._IvaId; } set { this._IvaId = value; } }
+
+ private System.Decimal? _Discount;
+ ///
+ /// 折扣
+ ///
+ [SugarColumn(ColumnName = "discount")]
+ public System.Decimal? Discount { get { return this._Discount; } set { this._Discount = value; } }
+
+ private System.Boolean? _IsProhibitedChangeDiscount;
+ ///
+ /// 是否禁止更改折扣:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_prohibited_change_discount")]
+ public System.Boolean? IsProhibitedChangeDiscount { get { return this._IsProhibitedChangeDiscount; } set { this._IsProhibitedChangeDiscount = value; } }
+
+ private System.Decimal? _CostPrice;
+ ///
+ /// 成本价
+ ///
+ [SugarColumn(ColumnName = "cost_price")]
+ public System.Decimal? CostPrice { get { return this._CostPrice; } set { this._CostPrice = value; } }
+
+ private System.String _Commentary;
+ ///
+ /// 批注
+ ///
+ [SugarColumn(ColumnName = "commentary")]
+ public System.String Commentary { get { return this._Commentary; } set { this._Commentary = value; } }
+
+ private System.Boolean? _IsTemporary;
+ ///
+ /// 是否是临时的:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_temporary")]
+ public System.Boolean? IsTemporary { get { return this._IsTemporary; } set { this._IsTemporary = value; } }
+
+ private System.Int32? _OrderId;
+ ///
+ /// 订单id
+ ///
+ [SugarColumn(ColumnName = "order_id")]
+ public System.Int32? OrderId { get { return this._OrderId; } set { this._OrderId = value; } }
+
+ private System.Decimal? _PackageAmount;
+ ///
+ /// 包装数量(包数)
+ ///
+ [SugarColumn(ColumnName = "package_amount")]
+ public System.Decimal? PackageAmount { get { return this._PackageAmount; } set { this._PackageAmount = value; } }
+
+ private System.Decimal? _Total;
+ ///
+ /// 合计
+ ///
+ [SugarColumn(ColumnName = "total")]
+ public System.Decimal? Total { get { return this._Total; } set { this._Total = value; } }
+
+ private System.String _Remark;
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public System.String Remark { get { return this._Remark; } set { this._Remark = value; } }
+
+ private System.String _DelFlag;
+ ///
+ /// 删除标记:1 删除 0 未删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public System.String DelFlag { get { return this._DelFlag; } set { this._DelFlag = value; } }
+
+ private System.String _UnitName;
+ ///
+ /// 单位名称
+ ///
+ [SugarColumn(ColumnName = "unit_name")]
+ public System.String UnitName { get { return this._UnitName; } set { this._UnitName = value; } }
+
+ private System.String _PurchaseSpec;
+ ///
+ /// 进货规格
+ ///
+ [SugarColumn(ColumnName = "purchase_spec")]
+ public System.String PurchaseSpec { get { return this._PurchaseSpec; } set { this._PurchaseSpec = value; } }
+
+ private System.Int32? _GoodsClassId;
+ ///
+ /// 商品类别
+ ///
+ [SugarColumn(ColumnName = "goods_class_id")]
+ public System.Int32? GoodsClassId { get { return this._GoodsClassId; } set { this._GoodsClassId = value; } }
+
+ private System.String _GoodsClassName;
+ ///
+ /// 商品类别名称
+ ///
+ [SugarColumn(ColumnName = "goods_class_name")]
+ public System.String GoodsClassName { get { return this._GoodsClassName; } set { this._GoodsClassName = value; } }
+
+ private System.Int32? _GoodsBrandId;
+ ///
+ /// 商品品牌
+ ///
+ [SugarColumn(ColumnName = "goods_brand_id")]
+ public System.Int32? GoodsBrandId { get { return this._GoodsBrandId; } set { this._GoodsBrandId = value; } }
+
+ private System.String _GoodsBrandName;
+ ///
+ /// 商品品牌名称
+ ///
+ [SugarColumn(ColumnName = "goods_brand_name")]
+ public System.String GoodsBrandName { get { return this._GoodsBrandName; } set { this._GoodsBrandName = value; } }
+
+ private System.Int32 _Id;
+ ///
+ /// 主键
+ ///
+ [SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
+ public System.Int32 Id { get { return this._Id; } set { this._Id = value; } }
+
+ private System.Int32 _TenantId;
+ ///
+ /// 所属租户id
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public System.Int32 TenantId { get { return this._TenantId; } set { this._TenantId = value; } }
+
+ [SugarColumn(IsIgnore = true)]
+ public int Index { get; set; }
+ }
+
+ public class ViewModelOrderAlbaranDetail: EOrderAlbaranDetail
+ {
+
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturn.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturn.cs
new file mode 100644
index 000000000..fd02d71ef
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturn.cs
@@ -0,0 +1,381 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HONORCSData.Order
+{
+ ///
+ /// 退货单
+ ///
+ [SugarTable("order_return")]
+ public class EOrderReturn
+ {
+ ///
+ /// 退货单
+ ///
+
+ public EOrderReturn()
+ {
+ }
+
+ private System.Int32 _OrderReturnId;
+ ///
+ /// 主键id
+ ///
+ [SugarColumn(IsPrimaryKey = true, ColumnName = "order_return_id")]
+ public System.Int32 OrderReturnId { get { return this._OrderReturnId; } set { this._OrderReturnId = value; } }
+
+ private System.Int32? _ServerAccountId;
+ ///
+ /// 服务器端账户id
+ ///
+ [SugarColumn(ColumnName = "server_account_id")]
+ public System.Int32? ServerAccountId { get { return this._ServerAccountId; } set { this._ServerAccountId = value; } }
+
+ private System.DateTime? _ReturnTime;
+ ///
+ /// 退货日期
+ ///
+ [SugarColumn(ColumnName = "return_time")]
+ public System.DateTime? ReturnTime { get { return this._ReturnTime; } set { this._ReturnTime = value; } }
+
+ private System.DateTime? _EntryTime;
+ ///
+ /// 录入时间
+ ///
+ [SugarColumn(ColumnName = "entry_time")]
+ public System.DateTime? EntryTime { get { return this._EntryTime; } set { this._EntryTime = value; } }
+
+ private System.String _OriginDocType;
+ ///
+ /// 原始文件类型
+ ///
+ [SugarColumn(ColumnName = "origin_doc_type")]
+ public System.String OriginDocType { get { return this._OriginDocType; } set { this._OriginDocType = value; } }
+
+ private System.Int32? _OriginDocId;
+ ///
+ /// 原始文件编号
+ ///
+ [SugarColumn(ColumnName = "origin_doc_id")]
+ public System.Int32? OriginDocId { get { return this._OriginDocId; } set { this._OriginDocId = value; } }
+
+ private System.String _DestinationDocType;
+ ///
+ /// 目的文件类型
+ ///
+ [SugarColumn(ColumnName = "destination_doc_type")]
+ public System.String DestinationDocType { get { return this._DestinationDocType; } set { this._DestinationDocType = value; } }
+
+ private System.Int32? _DestinationDocId;
+ ///
+ /// 目的文件编号
+ ///
+ [SugarColumn(ColumnName = "destination_doc_id")]
+ public System.Int32? DestinationDocId { get { return this._DestinationDocId; } set { this._DestinationDocId = value; } }
+
+ private System.Int16? _ChargeType;
+ ///
+ /// 收费类型
+ ///
+ [SugarColumn(ColumnName = "charge_type")]
+ public System.Int16? ChargeType { get { return this._ChargeType; } set { this._ChargeType = value; } }
+
+ private System.Decimal? _Cash;
+ ///
+ /// 现金
+ ///
+ [SugarColumn(ColumnName = "cash")]
+ public System.Decimal? Cash { get { return this._Cash; } set { this._Cash = value; } }
+
+ private System.Decimal? _Discount;
+ ///
+ /// 折扣
+ ///
+ [SugarColumn(ColumnName = "discount")]
+ public System.Decimal? Discount { get { return this._Discount; } set { this._Discount = value; } }
+
+ private System.Decimal? _DirectDiscount;
+ ///
+ /// 直接折扣
+ ///
+ [SugarColumn(ColumnName = "direct_discount")]
+ public System.Decimal? DirectDiscount { get { return this._DirectDiscount; } set { this._DirectDiscount = value; } }
+
+ private System.Decimal? _Total;
+ ///
+ /// 共计
+ ///
+ [SugarColumn(ColumnName = "total")]
+ public System.Decimal? Total { get { return this._Total; } set { this._Total = value; } }
+
+ private System.Decimal? _TotalDiscount;
+ ///
+ /// 折扣总计
+ ///
+ [SugarColumn(ColumnName = "total_discount")]
+ public System.Decimal? TotalDiscount { get { return this._TotalDiscount; } set { this._TotalDiscount = value; } }
+
+ private System.Decimal? _TotalVale;
+ ///
+ /// vale代金券总计
+ ///
+ [SugarColumn(ColumnName = "total_vale")]
+ public System.Decimal? TotalVale { get { return this._TotalVale; } set { this._TotalVale = value; } }
+
+ private System.Decimal? _Profit;
+ ///
+ /// 利润
+ ///
+ [SugarColumn(ColumnName = "profit")]
+ public System.Decimal? Profit { get { return this._Profit; } set { this._Profit = value; } }
+
+ private System.Decimal? _TotalPayment;
+ ///
+ /// 付款总计
+ ///
+ [SugarColumn(ColumnName = "total_payment")]
+ public System.Decimal? TotalPayment { get { return this._TotalPayment; } set { this._TotalPayment = value; } }
+
+ private System.Decimal? _TotalNumber;
+ ///
+ /// 总数量
+ ///
+ [SugarColumn(ColumnName = "total_number")]
+ public System.Decimal? TotalNumber { get { return this._TotalNumber; } set { this._TotalNumber = value; } }
+
+ private System.Decimal? _TotalCash;
+ ///
+ /// 总现金
+ ///
+ [SugarColumn(ColumnName = "total_cash")]
+ public System.Decimal? TotalCash { get { return this._TotalCash; } set { this._TotalCash = value; } }
+
+ private System.Int16? _IvaRule;
+ ///
+ /// iva规则(id)
+ ///
+ [SugarColumn(ColumnName = "iva_rule")]
+ public System.Int16? IvaRule { get { return this._IvaRule; } set { this._IvaRule = value; } }
+
+ private System.Int32? _IvaId;
+ ///
+ /// iva_id
+ ///
+ [SugarColumn(ColumnName = "iva_id")]
+ public System.Int32? IvaId { get { return this._IvaId; } set { this._IvaId = value; } }
+
+ private System.Int16? _UsePrice;
+ ///
+ /// 使用价格:1 零售价 2 会员价 3 进货价
+ ///
+ [SugarColumn(ColumnName = "use_price")]
+ public System.Int16? UsePrice { get { return this._UsePrice; } set { this._UsePrice = value; } }
+
+ private System.Int16? _CashdrawerId;
+ ///
+ /// 收银箱编号
+ ///
+ [SugarColumn(ColumnName = "cashdrawer_id")]
+ public System.Int16? CashdrawerId { get { return this._CashdrawerId; } set { this._CashdrawerId = value; } }
+
+ private System.String _ClientNo;
+ ///
+ /// 会员/供应商编号
+ ///
+ [SugarColumn(ColumnName = "client_no")]
+ public System.String ClientNo { get { return this._ClientNo; } set { this._ClientNo = value; } }
+
+ private System.Int32? _AgentId;
+ ///
+ /// 代理商id
+ ///
+ [SugarColumn(ColumnName = "agent_id")]
+ public System.Int32? AgentId { get { return this._AgentId; } set { this._AgentId = value; } }
+
+ private System.Int32? _TransporterId;
+ ///
+ /// 运输商ID
+ ///
+ [SugarColumn(ColumnName = "transporter_id")]
+ public System.Int32? TransporterId { get { return this._TransporterId; } set { this._TransporterId = value; } }
+
+ private System.String _CarNo;
+ ///
+ /// 车辆编号
+ ///
+ [SugarColumn(ColumnName = "car_no")]
+ public System.String CarNo { get { return this._CarNo; } set { this._CarNo = value; } }
+
+ private System.Int32? _OperatorId;
+ ///
+ /// 操作员编号
+ ///
+ [SugarColumn(ColumnName = "operator_id")]
+ public System.Int32? OperatorId { get { return this._OperatorId; } set { this._OperatorId = value; } }
+
+ private System.Int32? _VerifierId;
+ ///
+ /// 审核员编号
+ ///
+ [SugarColumn(ColumnName = "verifier_id")]
+ public System.Int32? VerifierId { get { return this._VerifierId; } set { this._VerifierId = value; } }
+
+ private System.Int32? _StorehouseId;
+ ///
+ /// 仓库id
+ ///
+ [SugarColumn(ColumnName = "storehouse_id")]
+ public System.Int32? StorehouseId { get { return this._StorehouseId; } set { this._StorehouseId = value; } }
+
+ private System.String _AttachedDocSymbol;
+ ///
+ /// 附加文件符号
+ ///
+ [SugarColumn(ColumnName = "attached_doc_symbol")]
+ public System.String AttachedDocSymbol { get { return this._AttachedDocSymbol; } set { this._AttachedDocSymbol = value; } }
+
+ private System.Int32? _PrePaymentMethod;
+ ///
+ /// 预付款方式
+ ///
+ [SugarColumn(ColumnName = "pre_payment_method")]
+ public System.Int32? PrePaymentMethod { get { return this._PrePaymentMethod; } set { this._PrePaymentMethod = value; } }
+
+ private System.String _ReturnComputerName;
+ ///
+ /// 退款计算机名称
+ ///
+ [SugarColumn(ColumnName = "return_computer_name")]
+ public System.String ReturnComputerName { get { return this._ReturnComputerName; } set { this._ReturnComputerName = value; } }
+
+ private System.String _ComputerName;
+ ///
+ /// 计算机名称
+ ///
+ [SugarColumn(ColumnName = "computer_name")]
+ public System.String ComputerName { get { return this._ComputerName; } set { this._ComputerName = value; } }
+
+ private System.String _Hash;
+ ///
+ /// 哈希
+ ///
+ [SugarColumn(ColumnName = "hash")]
+ public System.String Hash { get { return this._Hash; } set { this._Hash = value; } }
+
+ private System.Int32? _CifId;
+ ///
+ /// cif_id(到岸编号)
+ ///
+ [SugarColumn(ColumnName = "cif_id")]
+ public System.Int32? CifId { get { return this._CifId; } set { this._CifId = value; } }
+
+ private System.String _SubStoreId;
+ ///
+ /// 子商店编号
+ ///
+ [SugarColumn(ColumnName = "sub_store_id")]
+ public System.String SubStoreId { get { return this._SubStoreId; } set { this._SubStoreId = value; } }
+
+ private System.Decimal? _AbonoTotal;
+ ///
+ /// abono总计
+ ///
+ [SugarColumn(ColumnName = "abono_total")]
+ public System.Decimal? AbonoTotal { get { return this._AbonoTotal; } set { this._AbonoTotal = value; } }
+
+ private System.Boolean? _IsCharged;
+ ///
+ /// 是否已收款:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_charged")]
+ public System.Boolean? IsCharged { get { return this._IsCharged; } set { this._IsCharged = value; } }
+
+ private System.Boolean? _IsLock;
+ ///
+ /// 是否锁定:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_lock")]
+ public System.Boolean? IsLock { get { return this._IsLock; } set { this._IsLock = value; } }
+
+ private System.Boolean? _IsCanceled;
+ ///
+ /// 是否取消:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_canceled")]
+ public System.Boolean? IsCanceled { get { return this._IsCanceled; } set { this._IsCanceled = value; } }
+
+ private System.String _IsModify;
+ ///
+ /// 是否修改:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_modify")]
+ public System.String IsModify { get { return this._IsModify; } set { this._IsModify = value; } }
+
+ private System.Boolean? _IsSendEmail;
+ ///
+ /// 是否发送电子邮件:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_send_email")]
+ public System.Boolean? IsSendEmail { get { return this._IsSendEmail; } set { this._IsSendEmail = value; } }
+
+ private System.String _Remark;
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public System.String Remark { get { return this._Remark; } set { this._Remark = value; } }
+
+ private System.String _OrderReturnNo;
+ ///
+ /// 订单编号
+ ///
+ [SugarColumn(ColumnName = "order_return_no")]
+ public System.String OrderReturnNo { get { return this._OrderReturnNo; } set { this._OrderReturnNo = value; } }
+
+ private System.Int16? _OrderReturnType;
+ ///
+ /// 订单类型:1 采购 2 销售
+ ///
+ [SugarColumn(ColumnName = "order_return_type")]
+ public System.Int16? OrderReturnType { get { return this._OrderReturnType; } set { this._OrderReturnType = value; } }
+
+ private System.Int32? _CreateTime;
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(ColumnName = "create_time")]
+ public System.Int32? CreateTime { get { return this._CreateTime; } set { this._CreateTime = value; } }
+
+ private System.Int32? _UpdateTime;
+ ///
+ /// 修改时间
+ ///
+ [SugarColumn(ColumnName = "update_time")]
+ public System.Int32? UpdateTime { get { return this._UpdateTime; } set { this._UpdateTime = value; } }
+
+ private System.String _DelFlag;
+ ///
+ /// 删除标记:1 删除 0 未删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public System.String DelFlag { get { return this._DelFlag; } set { this._DelFlag = value; } }
+
+ private System.String _VerifyStatus;
+ ///
+ /// 审核状态:1 已审核 0 未审核
+ ///
+ [SugarColumn(ColumnName = "verify_status")]
+ public System.String VerifyStatus { get { return this._VerifyStatus; } set { this._VerifyStatus = value?.Trim(); } }
+
+ private System.Int32 _TenantId;
+ ///
+ /// 所属租户
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public System.Int32 TenantId { get { return this._TenantId; } set { this._TenantId = value; } }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturnDetail.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturnDetail.cs
new file mode 100644
index 000000000..a5fe1cd6b
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/EOrderReturnDetail.cs
@@ -0,0 +1,202 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HONORCSData.Order
+{
+ ///
+ /// 退货详情
+ ///
+ [SugarTable("order_return_detail")]
+ public class EOrderReturnDetail
+ {
+ ///
+ /// 退货详情
+ ///
+ public EOrderReturnDetail()
+ {
+ }
+
+ private System.Int32 _OrderReturnId;
+ ///
+ /// 退货单编号
+ ///
+ [SugarColumn(ColumnName = "order_return_id")]
+ public System.Int32 OrderReturnId { get { return this._OrderReturnId; } set { this._OrderReturnId = value; } }
+
+ private System.String _GoodsNo;
+ ///
+ /// 商品编号
+ ///
+ [SugarColumn(ColumnName = "goods_no")]
+ public System.String GoodsNo { get { return this._GoodsNo; } set { this._GoodsNo = value; } }
+
+ private System.String _BarCode;
+ ///
+ /// 条码
+ ///
+ [SugarColumn(ColumnName = "bar_code")]
+ public System.String BarCode { get { return this._BarCode; } set { this._BarCode = value; } }
+
+ private System.Boolean _IsBlanceBarCode;
+ ///
+ /// 是否对称条码:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_blance_bar_code")]
+ public System.Boolean IsBlanceBarCode { get { return this._IsBlanceBarCode; } set { this._IsBlanceBarCode = value; } }
+
+ private System.String _SpanishName;
+ ///
+ /// 西文名称
+ ///
+ [SugarColumn(ColumnName = "spanish_name")]
+ public System.String SpanishName { get { return this._SpanishName; } set { this._SpanishName = value; } }
+
+ private System.String _ChineseName;
+ ///
+ /// 中文名称
+ ///
+ [SugarColumn(ColumnName = "chinese_name")]
+ public System.String ChineseName { get { return this._ChineseName; } set { this._ChineseName = value; } }
+
+ private System.Decimal? _Price;
+ ///
+ /// 价格
+ ///
+ [SugarColumn(ColumnName = "price")]
+ public System.Decimal? Price { get { return this._Price; } set { this._Price = value; } }
+
+ private System.Decimal? _Number;
+ ///
+ /// 数量
+ ///
+ [SugarColumn(ColumnName = "number")]
+ public System.Decimal? Number { get { return this._Number; } set { this._Number = value; } }
+
+ private System.Decimal? _Iva;
+ ///
+ /// iva
+ ///
+ [SugarColumn(ColumnName = "iva")]
+ public System.Decimal? Iva { get { return this._Iva; } set { this._Iva = value; } }
+
+ private System.Decimal? _Req;
+ ///
+ /// req
+ ///
+ [SugarColumn(ColumnName = "req")]
+ public System.Decimal? Req { get { return this._Req; } set { this._Req = value; } }
+
+ private System.Int32? _IvaId;
+ ///
+ /// iva_id
+ ///
+ [SugarColumn(ColumnName = "iva_id")]
+ public System.Int32? IvaId { get { return this._IvaId; } set { this._IvaId = value; } }
+
+ private System.Decimal? _Discount;
+ ///
+ /// 折扣
+ ///
+ [SugarColumn(ColumnName = "discount")]
+ public System.Decimal? Discount { get { return this._Discount; } set { this._Discount = value; } }
+
+ private System.Boolean? _IsProhibitedChangeDiscount;
+ ///
+ /// 是否禁止更改折扣:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_prohibited_change_discount")]
+ public System.Boolean? IsProhibitedChangeDiscount { get { return this._IsProhibitedChangeDiscount; } set { this._IsProhibitedChangeDiscount = value; } }
+
+ private System.Decimal? _CostPrice;
+ ///
+ /// 成本价
+ ///
+ [SugarColumn(ColumnName = "cost_price")]
+ public System.Decimal? CostPrice { get { return this._CostPrice; } set { this._CostPrice = value; } }
+
+ private System.String _Commentary;
+ ///
+ /// 批注
+ ///
+ [SugarColumn(ColumnName = "commentary")]
+ public System.String Commentary { get { return this._Commentary; } set { this._Commentary = value; } }
+
+ private System.Boolean? _IsTemporary;
+ ///
+ /// 是否是临时的:1 是 0 否
+ ///
+ [SugarColumn(ColumnName = "is_temporary")]
+ public System.Boolean? IsTemporary { get { return this._IsTemporary; } set { this._IsTemporary = value; } }
+
+ private System.Int32? _OrderId;
+ ///
+ /// 订单id
+ ///
+ [SugarColumn(ColumnName = "order_id")]
+ public System.Int32? OrderId { get { return this._OrderId; } set { this._OrderId = value; } }
+
+ private System.Decimal? _PackageAmount;
+ ///
+ /// 包装数量(包数)
+ ///
+ [SugarColumn(ColumnName = "package_amount")]
+ public System.Decimal? PackageAmount { get { return this._PackageAmount; } set { this._PackageAmount = value; } }
+
+ private System.Decimal? _Total;
+ ///
+ /// 合计
+ ///
+ [SugarColumn(ColumnName = "total")]
+ public System.Decimal? Total { get { return this._Total; } set { this._Total = value; } }
+
+ private System.String _Remark;
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public System.String Remark { get { return this._Remark; } set { this._Remark = value; } }
+
+ private System.String _DelFlag;
+ ///
+ /// 删除标记:1 删除 0 未删除
+ ///
+ [SugarColumn(ColumnName = "del_flag")]
+ public System.String DelFlag { get { return this._DelFlag; } set { this._DelFlag = value; } }
+
+ private System.String _UnitName;
+ ///
+ /// 单位名称
+ ///
+ [SugarColumn(ColumnName = "unit_name")]
+ public System.String UnitName { get { return this._UnitName; } set { this._UnitName = value; } }
+
+ private System.String _PurchaseSpec;
+ ///
+ /// 进货规格
+ ///
+ [SugarColumn(ColumnName = "purchase_spec")]
+ public System.String PurchaseSpec { get { return this._PurchaseSpec; } set { this._PurchaseSpec = value; } }
+
+ private System.Int32 _Id;
+ ///
+ /// 主键
+ ///
+ [SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
+ public System.Int32 Id { get { return this._Id; } set { this._Id = value; } }
+
+ private System.Int32 _TenantId;
+ ///
+ /// 所属租户id
+ ///
+ [SugarColumn(ColumnName = "tenant_id")]
+ public System.Int32 TenantId { get { return this._TenantId; } set { this._TenantId = value; } }
+
+
+ [SugarColumn(IsIgnore = true)]
+ public int Index { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/PurchaseDetailModel.cs b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/PurchaseDetailModel.cs
new file mode 100644
index 000000000..e714cfd4d
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/Unit/Custom1/PurchaseDetailModel.cs
@@ -0,0 +1,162 @@
+using HONORCSData;
+using HONORCSData.Goods;
+using HONORCSData.Order;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using HONORCSData.Order;
+namespace OrmTest
+{
+ ///
+ /// 采购明细
+ ///
+ public class PurchaseDetailModel
+ {
+ public int Index { get; set; }
+
+ ///
+ /// 录入日期
+ ///
+ public DateTime? EntryTime { get; set; }
+
+ ///
+ /// 编号
+ ///
+ public string No { get; set; }
+
+ ///
+ /// 类型
+ ///
+ public int Type { get; set; }
+
+ public string GoodsNo { get; set; }
+
+ public string GoodsName { get; set; }
+
+
+ public string GoodsCategory { get; set; }
+
+
+ public string BrandName { get; set; }
+
+
+ public decimal? Number { get; set; }
+
+
+ public decimal? Price { get; set; }
+
+ public decimal TotalPrice
+ {
+ get
+ {
+ if (Number == null || Price == null) return 0;
+ return Number.Value * Price.Value;
+ }
+ }
+
+
+ }
+ public class CustomTest1
+ {
+ ///
+ /// 采购明细汇总
+ ///
+ ///
+ ///
+ ///
+ public static async Task GetPurchaseDetailPageAsync(SqlSugarClient Db)
+ {
+ Db.CodeFirst.InitTables();
+ Db.CodeFirst.InitTables();
+ //入库单
+ Db.Insertable(new EOrderAlbaranDetail()
+ {
+ AlbaranId = 1,
+ BarCode = "a",
+ ChineseName = "a",
+ Commentary = "a",
+ CostPrice = 1,
+ DelFlag = "a",
+ Discount = 1,
+ GoodsBrandId = 1,
+ GoodsBrandName = "a",
+ GoodsClassId = 1,
+ GoodsClassName = "a",
+ GoodsNo = "a",
+ Id = new Random().Next(0, 99999999),
+ Index = 1,
+ IsBlanceBarCode = true,
+ IsProhibitedChangeDiscount = true,
+ IsTemporary = true,
+ Iva = 1,
+ IvaId = 1,
+ Number = 1,
+ OrderId = 1,
+ PackageAmount = 1,
+ Price = 1,
+ PurchaseSpec = "",
+ Remark = "a",
+ Req = 1,
+ SpanishName = "a",
+ TenantId = 1,
+ Total = 1,
+ UnitName = "a"
+ }).ExecuteCommand();
+ var query1 = Db.Queryable((d, h, g, c, b) => new JoinQueryInfos(
+ JoinType.Left, h.AlbaranId == d.AlbaranId,
+ JoinType.Left, d.GoodsNo == g.GoodsNo,
+ JoinType.Left, g.GoodsClassId == c.GoodsClassId,
+ JoinType.Left, g.BrandId == b.BrandId
+ ))
+ .Where((d, h, g, c, b) => h.AlbaranType == null) //固定入库单
+ .Select((d, h, g, c, b) => new PurchaseDetailModel
+ {
+ EntryTime = h.EntryTime,
+ No = h.AlbaranNo,
+ Type = 1,
+ GoodsNo = d.GoodsNo,
+ GoodsName = g.SpanishName,
+ GoodsCategory = c.SpanishName,
+ BrandName = b.BranchSpanishName,
+ Number = d.Number,
+ Price = d.Price
+ });
+
+ //退货单
+ var query2 = Db.Queryable((d, h, g, c, b) => new JoinQueryInfos(
+ JoinType.Left, h.OrderReturnId == d.OrderReturnId,
+ JoinType.Left, d.GoodsNo == g.GoodsNo,
+ JoinType.Left, g.GoodsClassId == c.GoodsClassId,
+ JoinType.Left, g.BrandId == b.BrandId
+ )).Where((d, h, g, c, b) => h.OrderReturnType == 1) //固定入库单
+ .Select((d, h, g, c, b) => new PurchaseDetailModel
+ {
+ EntryTime = h.EntryTime,
+ No = h.OrderReturnNo,
+ Type = 2,
+ GoodsNo = d.GoodsNo,
+ GoodsName = g.SpanishName,
+ GoodsCategory = c.SpanishName,
+ BrandName = b.BranchSpanishName,
+ Number = d.Number,
+ Price = d.Price
+ });
+ SqlSugar.RefAsync totalNum = 0;
+
+ var res2 = await query2.Clone().ToPageListAsync(1, 2, totalNum);
+ var res = await Db.UnionAll(query1, query2).ToPageListAsync(1, 2, totalNum);
+
+ var q = Db.Queryable().Where(it => it.Id == 1).Select(it => new { id=1});
+ var q2 = q.Clone();
+ var x = q.ToList();
+ var y = q2.ToList();
+ //var res = await Db.UnionAll(query1.Clone(), query2.Clone()).ToPageListAsync(1, 10, totalNum);
+
+ }
+
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Models/ViewOrder.cs b/Src/Asp.Net/MySqlConnectorTest/Models/ViewOrder.cs
new file mode 100644
index 000000000..fcd465747
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Models/ViewOrder.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class ViewOrder:Order
+ {
+ public string CustomName { get; set; }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/MySqlConnectorTest.csproj b/Src/Asp.Net/MySqlConnectorTest/MySqlConnectorTest.csproj
new file mode 100644
index 000000000..4b705ff09
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/MySqlConnectorTest.csproj
@@ -0,0 +1,138 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7F705C44-F878-4706-AB9B-8D35030A8222}
+ Exe
+ MySqlConnectorTest
+ MySqlConnectorTest
+ v4.6
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\MySqlConnector.1.2.1\lib\net45\MySqlConnector.dll
+
+
+
+ ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll
+
+
+
+
+ ..\packages\System.Memory.4.5.0\lib\netstandard1.1\System.Memory.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {d131ee06-bad4-4b80-b7de-d6f539087644}
+ SqlSugar.MySqlConnector
+
+
+ {489bb790-226c-4fad-8d1e-51d72a7ff8e5}
+ SqlSugar
+
+
+
+
\ No newline at end of file
diff --git a/Src/Asp.Net/MySqlConnectorTest/Program.cs b/Src/Asp.Net/MySqlConnectorTest/Program.cs
new file mode 100644
index 000000000..9481f1940
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Program.cs
@@ -0,0 +1,41 @@
+using System;
+
+namespace OrmTest
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ //Demo
+ Demo0_SqlSugarClient.Init();
+ Demo1_Queryable.Init();
+ Demo2_Updateable.Init();
+ Demo3_Insertable.Init();
+ DemoN_SplitTable.Init();
+ Demo4_Deleteable.Init();
+ Demo5_SqlQueryable.Init();
+ Demo6_Queue.Init();
+ Demo7_Ado.Init();
+ Demo8_Saveable.Init();
+ Demo9_EntityMain.Init();
+ DemoA_DbMain.Init();
+ DemoB_Aop.Init();
+ DemoC_GobalFilter.Init();
+ DemoD_DbFirst.Init(); ;
+ DemoE_CodeFirst.Init();
+ DemoF_Utilities.Init();
+ DemoG_SimpleClient.Init();
+ DemoJ_Report.Init();
+ //Unit test
+ //NewUnitTest.Init();
+
+ //Rest Data
+ NewUnitTest.RestData();
+
+ Console.WriteLine("all successfully.");
+ Console.ReadKey();
+ }
+
+
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/Properties/AssemblyInfo.cs b/Src/Asp.Net/MySqlConnectorTest/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..4ae25b1cb
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MySqlConnectorTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MySqlConnectorTest")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("7f705c44-f878-4706-ab9b-8d35030a8222")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Src/Asp.Net/MySqlConnectorTest/UnitTest/Main.cs b/Src/Asp.Net/MySqlConnectorTest/UnitTest/Main.cs
new file mode 100644
index 000000000..93119fffd
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/UnitTest/Main.cs
@@ -0,0 +1,50 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ public partial class NewUnitTest
+ {
+ public static SqlSugarClient Db=> new SqlSugarClient(new ConnectionConfig()
+ {
+ DbType = DbType.MySqlConnector,
+ ConnectionString = Config.ConnectionString,
+ InitKeyType = InitKeyType.Attribute,
+ IsAutoCloseConnection = true,
+ AopEvents = new AopEvents
+ {
+ OnLogExecuting = (sql, p) =>
+ {
+ Console.WriteLine(sql);
+ Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
+ }
+ }
+ });
+
+ public static void RestData()
+ {
+ Db.DbMaintenance.TruncateTable();
+ Db.DbMaintenance.TruncateTable();
+ }
+ public static void Init()
+ {
+ UnitCustom01.Init();
+ UCustom06.Init();
+ Bulk();
+ Insert();
+ Queue();
+ CodeFirst();
+ Updateable();
+ Json();
+ Ado();
+ Queryable();
+ QueryableAsync();
+ //Thread();
+ //Thread2();
+ //Thread3();
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/UnitTest/UAdo.cs b/Src/Asp.Net/MySqlConnectorTest/UnitTest/UAdo.cs
new file mode 100644
index 000000000..f2578cf29
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/UnitTest/UAdo.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public partial class NewUnitTest
+ {
+ public static void Ado()
+ {
+
+ var task1 = Db.Ado.GetScalarAsync("select 1");
+ task1.Wait();
+ UValidate.Check(1, task1.Result, "ado");
+
+ var task2 = Db.Ado.GetIntAsync("select 2");
+ task2.Wait();
+ UValidate.Check(2, task2.Result, "ado");
+
+
+ var task3 = Db.Ado.GetLongAsync("select 3");
+ task3.Wait();
+ UValidate.Check(3, task3.Result, "ado");
+
+
+ var task4 = Db.Ado.GetDataTableAsync("select 4 as id");
+ task4.Wait();
+ UValidate.Check(4, task4.Result.Rows[0]["id"], "ado");
+
+
+ var task5 = Db.Ado.GetInt("select @id as id",new { id=5});
+ UValidate.Check(5, task5, "ado");
+
+
+
+ var task6 = Db.Ado.SqlQuery("select @id as id", new { id = 5 });
+ UValidate.Check(5, task6[0].id, "ado");
+
+
+ var task7 = Db.Ado.SqlQueryAsync("select @id as id", new { id = 7 });
+ task7.Wait();
+ UValidate.Check(7, task7.Result[0].id, "ado");
+
+
+ var task8 = Db.Ado.SqlQueryAsync("select 8 as id");
+ task8.Wait();
+ UValidate.Check(8, task8.Result[0].id, "ado");
+
+ var task9=Db.Ado.SqlQuery("select * from `order`;select * from OrderDetail");
+
+ var task10 = Db.Ado.SqlQueryAsync("select * from `order`;select * from OrderDetail");
+ task10.Wait();
+ }
+ }
+}
diff --git a/Src/Asp.Net/MySqlConnectorTest/UnitTest/UBulkCopy.cs b/Src/Asp.Net/MySqlConnectorTest/UnitTest/UBulkCopy.cs
new file mode 100644
index 000000000..9ef952c56
--- /dev/null
+++ b/Src/Asp.Net/MySqlConnectorTest/UnitTest/UBulkCopy.cs
@@ -0,0 +1,212 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OrmTest
+{
+ public partial class NewUnitTest
+ {
+ public static string bulkData1 = @"{""data"":[{""id"":0,""robot_wx_id"":""wxid_0p3bww1ouyvi12"",""robot_serial_no"":""3927EE296470127DD1F1DF6274467A7A"",""device_user_serial_no"":""F27C2578D8004E9F8644EBC023C0A582"",""wx_account"":""lvqiujingliu1986"",""wx_password"":""8836MjQ2MWFhYWEyMzQ5"",""wx_alias"":""lvqiujingliu1986"",""nick_name"":""闾丘睛六"",""base64_nick_name"":""6Ze+5LiY552b5YWt"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/VlhejJkdGe5YhcXdIVHYibxKbntVE85ZiayxtN2NnSibSViapXLEPY2mt1kHrZbqXnfgenBnNrp8Cx95YN1Uxic2E7Gzdfk2DSnYeUuR2QVpQJ28/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""1541723256"",""update_time"":""2022-01-12T09:57:13.377"",""create_time"":""2021-12-24T16:08:20.84"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_ln20qwymng8422"",""robot_serial_no"":""39289F28EAD96B4474A608919011FDEB"",""device_user_serial_no"":""20200917101004889010110000391"",""wx_account"":""ik50u73"",""wx_password"":""3uvhM3V2aDN1dmg2Z3Fl"",""wx_alias"":""ik50u73"",""nick_name"":""缪茹茹"",""base64_nick_name"":""57yq6Iy56Iy5"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/Q7gjPhRR5ahEIP3DWyzIVvj1dPkGRTXia4hBTEY4VBCjq45jBkXc2A4ZwjWGhgKZ8AWDWt6LZpL3qic5dN2t5H5Nz1BI3iaqWlqBpZYticftusE/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""2342964524"",""update_time"":""2022-01-11T19:26:38.86"",""create_time"":""2020-07-08T14:26:57.907"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_0prnyg6n7aat22"",""robot_serial_no"":""39281E97D2F28A1BA848EED509D1D914"",""device_user_serial_no"":""20220105175222407210210002286"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":"""",""nick_name"":""烈文"",""base64_nick_name"":""54OI5paH"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/3S5EfQYud7JQ9bibib2sUHSE18HskHNF4yE6DrgvjRbBWawfreZlR6KR0ZhE5MrFWWv6b4JLHQdUUlWicqnWWvhgtdLpAlicURuHeD0k6qvX7dE/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""2483638563"",""update_time"":""2022-01-11T17:55:05.147"",""create_time"":""2021-10-15T13:30:50.637"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_rbhtxkd819ug21"",""robot_serial_no"":""3928E3EF41E241987190AAD5CD3896FA"",""device_user_serial_no"":""20211129100847022010210001354"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":""jammy__C"",""nick_name"":""婕"",""base64_nick_name"":""5amV"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/CB1XmYSqgFJ9no4HR6icKgnf8uJKGX8BQUqhsR9CoyFpqh3QxJCWMmGkslicXyVjiaCZyBjC9DL7eXBicOKnbe9kun5yW8cBlqSDhR0vIjGaOuQ/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""1083130244"",""update_time"":""2022-01-10T13:06:27.823"",""create_time"":""2021-09-27T11:33:16.327"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_opxbbhmzlakx12"",""robot_serial_no"":""392734726B89AFD98BD54F87A6F7A323"",""device_user_serial_no"":""C64EA13FFEDE4AC587E3E189CC32ED2B"",""wx_account"":""lugao1106"",""wx_password"":""9591Y2UxYnd3d3cxNTQ5"",""wx_alias"":""lugao1106"",""nick_name"":""逯缟"",""base64_nick_name"":""6YCv57yf"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/6O6v8T7HbFiag6MJTQErfNdoNhG08wQx4rXApdQfjdcnxEZFcjlOmB1mFJ4OfBYhkvhibUzdCegsY0YiaYtwpEtpg/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""202535294"",""update_time"":""2022-01-11T11:18:08.897"",""create_time"":""2021-11-19T16:29:19.907"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_fvmabxeptk9n12"",""robot_serial_no"":""392857A86E6E48690FC4648588F22E24"",""device_user_serial_no"":""20220108112325107110110008239"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":""jiangwi0603"",""nick_name"":""jason"",""base64_nick_name"":""amFzb24="",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/MEbn4icxcP6IDTiblzFfhfqwp0LaBAetP4Nobvk5xSTcd0jJtYljIN6BYh5nXEsCJyCGa0jSZrTczYcD0w1SaPb2eyYoKM0tLicx95Nz1q4XBQ/132"",""email"":""jiangwi0603@126.com"",""sex"":1,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""3063392316"",""update_time"":""2022-01-11T11:17:28.987"",""create_time"":""2022-01-11T11:16:49.84"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_00bzjyic7zdu22"",""robot_serial_no"":""39294970652FF9BD5E3412FC24F49368"",""device_user_serial_no"":""20200825110115450710110000807"",""wx_account"":""e45r41wi"",""wx_password"":""oc77b2M3N29jNzc3bzZ1ZXg0bHo="",""wx_alias"":""e45r41wi"",""nick_name"":"" 小川小"",""base64_nick_name"":""IOWwj+W3neWwjw=="",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/FQCiayUo0amVG3s9nulZph8Jeicd1oxklDpL67Zj4dE3ntmSuiaOA54v1D0sxGXnhfeicwDHIAA9ZrbkWoYaGeWoco1rRPxyIU0Dn0cxfyY21T4/132"",""email"":"""",""sex"":1,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""1811494957"",""update_time"":""2022-01-12T01:24:19.26"",""create_time"":""2020-04-03T00:18:51.277"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_11aabdewsz3421"",""robot_serial_no"":""39277ABBFE59C0C318D9271AE004BC8D"",""device_user_serial_no"":""20211217203325799310210000217"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":"""",""nick_name"":""\""碎花洋裙__"",""base64_nick_name"":""IueijuiKsea0i+ijmV9f"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/Cz96bFGqPJOeHuQLzM7M05QdN0IE6sichTg5SFCXVIqZCOXaLg1GNvkIWYVpwnfRJcTXcwia7eDkShRuPogulqXOVicgZ8pQWmAFjGxefqIYdE/132"",""email"":"""",""sex"":1,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""1947658881"",""update_time"":""2022-01-11T02:25:21.407"",""create_time"":""2021-10-22T15:18:50.34"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_c6iha3x4cxp622"",""robot_serial_no"":""39288C70A34DFF820A150FF29C5E99EE"",""device_user_serial_no"":""A02A33A4DDB54CD1834A21BB55F886FC"",""wx_account"":""15525425235"",""wx_password"":""9FD7OWIyOHh4eHg1MjM1"",""wx_alias"":""a15525425235"",""nick_name"":""华秀莲"",""base64_nick_name"":""5Y2O56eA6I6y"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/zupZQgKfg5Y6IyZfrYkzNjeIGYEJmQKjOTOXD78UnvibUqunpl04aldGqSYibj44opN53QMZDxa9T3cNib4hM4vqA/0"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":4,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""925715359"",""update_time"":""2022-01-12T10:17:48.453"",""create_time"":""2021-11-23T23:14:18.97"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_4l1ivs17ftb222"",""robot_serial_no"":""39269C2B524054811AFCAED61A7C9157"",""device_user_serial_no"":""20210520150600703910110004389"",""wx_account"":""stluohuiofgin"",""wx_password"":""627qNjI3cTYyN3F0d3dnMQ=="",""wx_alias"":""stluohuiofgin"",""nick_name"":""卜爽荷"",""base64_nick_name"":""5Y2c54i96I23"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/jUwh2gwmQMpBshR4gSkRlIDKdU76eRHKsibebr0abKl8AnevI0T8GaYeHicicEiaia12efM4pBaPKxD5FLaRSZDdZRveYMZibyKQlewxck9wSia2ho/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""2973613556"",""update_time"":""2022-01-11T05:36:24.143"",""create_time"":""2021-05-20T15:05:46.317"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_hdjl4c1rvhzm22"",""robot_serial_no"":""39283929293888060537D621C0C07670"",""device_user_serial_no"":""20211211080701699410210000733"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":"""",""nick_name"":""开心果2"",""base64_nick_name"":""5byA5b+D5p6cMg=="",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/CdiatnVopdM5oI6oQYoVaB7XObU6afg81hwVfJm1LvmP2dkjqT9stOJB4QGC6RSjdskuXjshDjLlt9nZCyMOiaLOOyCBmuIOV9RjEic3iaYyibDU/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""2709509370"",""update_time"":""2022-01-11T02:24:59.55"",""create_time"":""2021-09-11T06:29:24.603"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_ii0eb7q59cea22"",""robot_serial_no"":""392929B4976E9C3877F875BCDB68D7DF"",""device_user_serial_no"":""20210328130254263510110001471"",""wx_account"":""yyvliansuobh"",""wx_password"":""kd81a2Q4MWtkODFydXlwZzB0eQ=="",""wx_alias"":""yyvliansuobh"",""nick_name"":""赵苑"",""base64_nick_name"":""6LW16IuR"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/aqvibe2kL44hQrUZBd0SzpvVkwm5ORCUcSdmF2TeS29zu6ZXR5ECJt4WS3FHathburCYQGWYFaS9OfNOcjYddLTibbZM7J4zRlDFVxsqZWicMc/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""2463150744"",""update_time"":""2022-01-12T01:07:40.733"",""create_time"":""2021-03-28T13:02:39.89"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_4urf1eo9lh6922"",""robot_serial_no"":""392768D516AD31B5DD63FF7FE1F96234"",""device_user_serial_no"":""20200803170607244010110002026"",""wx_account"":""re41lii8zn"",""wx_password"":""o4d1bzRkMW80ZDF5ZDJrM3N4OTI="",""wx_alias"":""re41lii8zn"",""nick_name"":""小娥骄"",""base64_nick_name"":""5bCP5ail6aqE"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/wjAGzPlkibvAXIxFbHgobEbgqZNQOg0Ef8XEnvyX5ibciaPzdW8icS3ndjtIDicnnGZMg7IcplZGCeWdywqgkGichg6s7r1sJb3jLRcxkIQm3KA2Q/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""2873679361"",""update_time"":""2022-01-11T21:12:34.92"",""create_time"":""2020-03-28T23:34:47.013"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_swjhsaa2gljn22"",""robot_serial_no"":""39285985503DA5A84FC9028D72D45FFA"",""device_user_serial_no"":""20211207033654739920310255216"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":""LVOE1628"",""nick_name"":""静心"",""base64_nick_name"":""6Z2Z5b+D"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/hR5Gqfefr4pkPMv1E4DLyRBVryRXxe0ajpuR9JHMsiabBQXtdoic5rM9LIeEOABt6npy9eI88VJyfPjmYpuILAXA/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""373620837"",""update_time"":""2022-01-11T04:07:13.367"",""create_time"":""2021-12-06T21:48:28.217"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_t5rkwg6psqta12"",""robot_serial_no"":""392955F2CE8D0D85AC40DB5636F5ADFC"",""device_user_serial_no"":""20210302105529014210110000115"",""wx_account"":""Rjisngzhu109588"",""wx_password"":""frapZnJhcGZyYXBwOHkxOWlp"",""wx_alias"":""Rjisngzhu109588"",""nick_name"":""陈小凤"",""base64_nick_name"":""6ZmI5bCP5Yek"",""headimg_url"":""http://wx.qlogo.cn/mmhead/ver_1/LDkfKDR0sO5SAWjHP8c93Vx3FRK4u49mZ6HRkmSt9cOZwNndopH6Gz5x4K8UFC8Iv0u2cYROuqqCvH8v3DQnLqJqanKiaM4eT05ZMbg9XUgA/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""3414889675"",""update_time"":""2022-01-11T04:25:09.963"",""create_time"":""2021-03-02T10:55:19.837"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_1du1f7hsnj8422"",""robot_serial_no"":""39280F6BA859EE89842FA77ABB0DC039"",""device_user_serial_no"":""D572F85AA4B641D49C21FE5B14508F29"",""wx_account"":""15534029941"",""wx_password"":""96FBMjViN3p6eno5OTQx"",""wx_alias"":""ydh15534029941"",""nick_name"":""祁云亭"",""base64_nick_name"":""56WB5LqR5Lqt"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/nDCibWBVKQI3aMNpuiblF6YFHvFiaDN99ZINVZAShsgyx5cGmxu2H1hw4cQtKBD1r3ESYHMUVQnIwPp6BecK3TlEFWRYYayYH8sr3ibUPKbUc9U/0"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":4,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""18446744072072878797"",""update_time"":""2022-01-11T06:28:40.86"",""create_time"":""2022-01-09T17:03:50.27"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_btoq5obkvia312"",""robot_serial_no"":""3928C99084242D85837E58D49DD12F42"",""device_user_serial_no"":""B59DD35FEB764162990BFA8559F7408F"",""wx_account"":""19103155341"",""wx_password"":""cal8Y2FsOGNhbDg3eG5jMXc="",""wx_alias"":""Ks15904265536"",""nick_name"":""司寇恋云"",""base64_nick_name"":""5Y+45a+H5oGL5LqR"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/YdJvibiaA1X7KxedvZQ0z7gibD35QYCrItx9AvgO3CnbCZNELLloFbic2xecGHZbEv6IegTUHCQzHpxDTXRwtSbqiaib603SPw2fwdyO1ux5E6oZ0/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""1018112863"",""update_time"":""2022-01-12T04:56:09.393"",""create_time"":""2020-12-16T15:01:19.217"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_b7qz88olje4x21"",""robot_serial_no"":""39269A93540340FFB5BB6080E180FB48"",""device_user_serial_no"":""20211119182956000410210024676"",""wx_account"":"""",""wx_password"":"""",""wx_alias"":""guanmengsi_"",""nick_name"":""??梦·思小厨娘"",""base64_nick_name"":""8J+RhOaipsK35oCd5bCP5Y6o5aiY"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/OzeZ5ia3bn36BTjgLAZYAUmNNmSLgV5E1wcEcmDNNh5G4ZLjdLPw3GASUZ6iaMzDVtWCRMWibx9tIseedicicibAVVJKjT8BkaI6WrVjjNwuZUQQs/132"",""email"":"""",""sex"":2,""enabled"":true,""type"":30,""status"":10,""seal_status"":10,""protocol_type"":1,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""1753890521"",""update_time"":""2022-01-11T17:28:39.473"",""create_time"":""2021-10-12T16:41:17.513"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_pu59oaivtqs422"",""robot_serial_no"":""392838309D46DDE1A10788FD4A170D07"",""device_user_serial_no"":""20210705141209419610110001562"",""wx_account"":""dijiaohuan1958"",""wx_password"":""i2dyaTJkeWkyZHlhenVmeWx4Yg=="",""wx_alias"":""dijiaohuan1958"",""nick_name"":""经燕琴"",""base64_nick_name"":""57uP54eV55C0"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/IMGo9t3plEjOd4KA3iaaQk5NFfma3VrXkBCDia6q1R2lsxASZ3lsSahUYdvtBRyUPqteWd5tiaEmYdC6cGXeHue3IQ1f7OjYpvSSQwh7nZpbqI/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""38429044"",""update_time"":""2022-01-11T09:46:16.657"",""create_time"":""2021-07-05T14:11:39.643"",""remark"":""机器人信息·数据初始化""},{""id"":0,""robot_wx_id"":""wxid_0aax7lsdiql912"",""robot_serial_no"":""3928E79621B2BE780382762047ECE703"",""device_user_serial_no"":""986D325458CB4E69841A31720C2439C4"",""wx_account"":""18852589379"",""wx_password"":""pfolcGZvbHBmb2xhcHhuM2ZxNzE="",""wx_alias"":""XDMx3sngFNF"",""nick_name"":""柏白枫"",""base64_nick_name"":""5p+P55m95p6r"",""headimg_url"":""https://wx.qlogo.cn/mmhead/ver_1/FQ5pJrib0L2kluAGfbV5HZXH96v0rnGqwMsRNTVI8mwUwQuAYkAB3zHV3p5MGpQibCp6g9eVkCrsviaiaJ6aZzibGzibCRO9I98wWtaCu7revWkd8/132"",""email"":"""",""sex"":0,""enabled"":true,""type"":10,""status"":10,""seal_status"":10,""protocol_type"":2,""city_no"":"""",""province_no"":"""",""separation"":false,""parent_id"":0,""uin"":""160768034"",""update_time"":""2022-01-12T09:37:08.833"",""create_time"":""2020-12-04T16:30:41.407"",""remark"":""机器人信息·数据初始化""}]}";
+
+ public static void Bulk()
+ {
+ Db.CodeFirst.InitTables();
+ Db.DbMaintenance.TruncateTable();
+ var data = new UnitIdentity1()
+ {
+ Name = "jack"
+ };
+ Db.Fastest().BulkCopy(new List() {
+ data
+ });
+ var list = Db.Queryable().ToList();
+ if (list.Count != 1 || data.Name != list.First().Name)
+ {
+ throw new Exception("unit Bulk");
+ }
+ data.Name = "2";
+ Db.Fastest().BulkCopy(new List() {
+ data,
+ data
+ });
+ list = Db.Queryable().ToList();
+ if (list.Count != 3 || !list.Any(it => it.Name == "2"))
+ {
+ throw new Exception("unit Bulk");
+ }
+ Db.Fastest().BulkUpdate(new List() {
+ new UnitIdentity1(){
+ Id=1,
+ Name="222"
+ },
+ new UnitIdentity1(){
+ Id=2,
+ Name="111"
+ }
+ });
+ list = Db.Queryable().ToList();
+ if (list.First(it => it.Id == 1).Name != "222")
+ {
+ throw new Exception("unit Bulk");
+ }
+ if (list.First(it => it.Id == 2).Name != "111")
+ {
+ throw new Exception("unit Bulk");
+ }
+ if (list.First(it => it.Id == 3).Name != "2")
+ {
+ throw new Exception("unit Bulk");
+ }
+ Db.CodeFirst.InitTables();
+ Db.DbMaintenance.TruncateTable();
+ var count = Db.Fastest().AS("UnitIdentity111").BulkCopy(new List {
+ new UnitIdentity111111111(){ Id=1, Name="jack" }
+ });
+ if (count == 0)
+ {
+ throw new Exception("unit Bulk");
+ }
+ count = Db.Fastest().AS("UnitIdentity111").BulkUpdate(new List {
+ new UnitIdentity111111111(){ Id=1, Name="jack" }
+ });
+ if (count == 0)
+ {
+ throw new Exception("unit Bulk");
+ }
+ Db.CodeFirst.InitTables();
+ Db.Fastest().BulkUpdate(new List {
+ new UnitTable001(){ Id=1, table="a" }
+ });
+
+ Db.CodeFirst.InitTables();
+ Db.DbMaintenance.TruncateTable();
+ Db.Fastest