diff --git a/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/Config.cs b/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/Config.cs index 584e9a85f..f05b30340 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/Config.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/Config.cs @@ -16,7 +16,7 @@ namespace OrmTest /// Account have permission to create database /// 用有建库权限的数据库账号 /// - public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql"; + public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql; AllowLoadLocalInfile=true"; /// /// Account have permission to create database /// 用有建库权限的数据库账号 diff --git a/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/Main.cs index 3f5d2f01c..846389568 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + Bulk(); CodeFirst(); Updateable(); Json(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/UBulkCopy.cs b/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/UBulkCopy.cs new file mode 100644 index 000000000..a16840647 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/MySqlTest/UnitTest/UBulkCopy.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OrmTest +{ + public partial class NewUnitTest + { + 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"); + } + } + } + public class UnitIdentity1 + { + [SqlSugar.SugarColumn(IsPrimaryKey =true,IsIdentity =true)] + public int Id { get; set; } + public string Name { get; set; } + } +}