mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update driver
This commit is contained in:
parent
1db41a7e60
commit
7de3aaeeeb
@ -81,6 +81,7 @@ namespace SqlSugar
|
|||||||
cmd.Parameters.AddWithValue("@" + item.ColumnName, dataRow[item.ColumnName]);
|
cmd.Parameters.AddWithValue("@" + item.ColumnName, dataRow[item.ColumnName]);
|
||||||
}
|
}
|
||||||
i += await cmd.ExecuteNonQueryAsync();
|
i += await cmd.ExecuteNonQueryAsync();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
@ -101,6 +102,7 @@ namespace SqlSugar
|
|||||||
cmd.Parameters.AddWithValue("@" + item.ColumnName, dataRow[item.ColumnName]);
|
cmd.Parameters.AddWithValue("@" + item.ColumnName, dataRow[item.ColumnName]);
|
||||||
}
|
}
|
||||||
i += await cmd.ExecuteNonQueryAsync();
|
i += await cmd.ExecuteNonQueryAsync();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.5" />
|
||||||
<PackageReference Include="MySql.Data" Version="8.0.21" />
|
<PackageReference Include="MySql.Data" Version="8.0.21" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||||
<PackageReference Include="Npgsql" Version="4.1.3.1" />
|
<PackageReference Include="Npgsql" Version="5.0.7" />
|
||||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
|
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
|
||||||
<PackageReference Include="Oscar.Data.SqlClient" Version="4.0.4" />
|
<PackageReference Include="Oscar.Data.SqlClient" Version="4.0.4" />
|
||||||
<PackageReference Include="SqlSugarCore.Dm" Version="1.0.0" />
|
<PackageReference Include="SqlSugarCore.Dm" Version="1.0.0" />
|
||||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Bulk();
|
||||||
CodeFirst();
|
CodeFirst();
|
||||||
Updateable();
|
Updateable();
|
||||||
Json();
|
Json();
|
||||||
|
168
Src/Asp.NetCore2/SqlSeverTest/SqliteTest/UnitTest/UBulkCopy.cs
Normal file
168
Src/Asp.NetCore2/SqlSeverTest/SqliteTest/UnitTest/UBulkCopy.cs
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public partial class NewUnitTest
|
||||||
|
{
|
||||||
|
public static void Bulk()
|
||||||
|
{
|
||||||
|
if (Db.DbMaintenance.IsAnyTable("UnitIdentity1", false))
|
||||||
|
{
|
||||||
|
Db.DbMaintenance.DropTable("UnitIdentity1");
|
||||||
|
}
|
||||||
|
Db.CodeFirst.InitTables<UnitIdentity1>();
|
||||||
|
Db.DbMaintenance.TruncateTable<UnitIdentity1>();
|
||||||
|
var data = new UnitIdentity1()
|
||||||
|
{
|
||||||
|
Name = "jack"
|
||||||
|
};
|
||||||
|
Db.Fastest<UnitIdentity1>().BulkCopy(new List<UnitIdentity1>() {
|
||||||
|
data
|
||||||
|
});
|
||||||
|
var list=Db.Queryable<UnitIdentity1>().ToList();
|
||||||
|
if (list.Count != 1 || data.Name != list.First().Name)
|
||||||
|
{
|
||||||
|
throw new Exception("unit Bulk");
|
||||||
|
}
|
||||||
|
data.Name = "2";
|
||||||
|
Db.Fastest<UnitIdentity1>().BulkCopy(new List<UnitIdentity1>() {
|
||||||
|
data,
|
||||||
|
data
|
||||||
|
});
|
||||||
|
list = Db.Queryable<UnitIdentity1>().ToList();
|
||||||
|
if (list.Count != 3 || !list.Any(it=>it.Name=="2"))
|
||||||
|
{
|
||||||
|
throw new Exception("unit Bulk");
|
||||||
|
}
|
||||||
|
Db.Fastest<UnitIdentity1>().BulkUpdate(new List<UnitIdentity1>() {
|
||||||
|
new UnitIdentity1(){
|
||||||
|
Id=1,
|
||||||
|
Name="222"
|
||||||
|
},
|
||||||
|
new UnitIdentity1(){
|
||||||
|
Id=2,
|
||||||
|
Name="111"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
list = Db.Queryable<UnitIdentity1>().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<UnitIdentity111>();
|
||||||
|
Db.DbMaintenance.TruncateTable<UnitIdentity111>();
|
||||||
|
var count = Db.Fastest<UnitIdentity111111111>().AS("UnitIdentity111").BulkCopy(new List<UnitIdentity111111111> {
|
||||||
|
new UnitIdentity111111111(){ Id=1, Name="jack" }
|
||||||
|
});
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("unit Bulk");
|
||||||
|
}
|
||||||
|
count = Db.Fastest<UnitIdentity111111111>().AS("UnitIdentity111").BulkUpdate(new List<UnitIdentity111111111> {
|
||||||
|
new UnitIdentity111111111(){ Id=1, Name="jack" }
|
||||||
|
});
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("unit Bulk");
|
||||||
|
}
|
||||||
|
Db.CodeFirst.InitTables<UnitTable001>();
|
||||||
|
Db.Fastest<UnitTable001>().BulkUpdate(new List<UnitTable001> {
|
||||||
|
new UnitTable001(){ Id=1, table="a" }
|
||||||
|
});
|
||||||
|
|
||||||
|
Db.CodeFirst.InitTables<UnitBulk23131>();
|
||||||
|
Db.DbMaintenance.TruncateTable<UnitBulk23131>();
|
||||||
|
Db.Fastest<UnitBulk23131>().BulkCopy(new List<UnitBulk23131> {
|
||||||
|
new UnitBulk23131()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
table = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var list1 = Db.Queryable<UnitBulk23131>().ToList();
|
||||||
|
SqlSugar.Check.Exception(list1.First().table==true, "unit error");
|
||||||
|
Db.Fastest<UnitBulk23131>().BulkUpdate(new List<UnitBulk23131> {
|
||||||
|
new UnitBulk23131()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
table = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var list2=Db.Queryable<UnitBulk23131>().ToList();
|
||||||
|
SqlSugar.Check.Exception(list2.First().table==false, "unit error");
|
||||||
|
|
||||||
|
Db.DbMaintenance.TruncateTable<UnitBulk23131>();
|
||||||
|
Db.Fastest<UnitBulk23131>().BulkCopy(new List<UnitBulk23131> {
|
||||||
|
new UnitBulk23131()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
table = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var list3 = Db.Queryable<UnitBulk23131>().ToList();
|
||||||
|
SqlSugar.Check.Exception(list3.First().table == false, "unit error");
|
||||||
|
Db.Fastest<UnitBulk23131>().BulkUpdate(new List<UnitBulk23131> {
|
||||||
|
new UnitBulk23131()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
table = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
list3 = Db.Queryable<UnitBulk23131>().ToList();
|
||||||
|
SqlSugar.Check.Exception(list3.First().table == true, "unit error");
|
||||||
|
|
||||||
|
Db.DbMaintenance.TruncateTable<UnitBulk23131>();
|
||||||
|
Db.Fastest<UnitBulk23131>().BulkCopy(new List<UnitBulk23131> {
|
||||||
|
new UnitBulk23131()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
table = null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var list4 = Db.Queryable<UnitBulk23131>().ToList();
|
||||||
|
SqlSugar.Check.Exception(list4.First().table==true, "unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class UnitBulk23131
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType ="tinyint",Length =1,IsNullable =true)]
|
||||||
|
public bool? table { get; set; }
|
||||||
|
}
|
||||||
|
public class UnitTable001
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string table { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnitIdentity111
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
public class UnitIdentity111111111
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
public class UnitIdentity1
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user