SqlSugar源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

3 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using SqlSugar;
namespace OrmTest
{
public partial class NewUnitTest
{
private static void Fastest2()
{
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
{
ConnectionString =Config.ConnectionString,
3 years ago
DbType = DbType.SqlServer,
3 years ago
IsAutoCloseConnection = true
});
db.CodeFirst.InitTables<Test2>();
3 years ago
db.DbMaintenance.TruncateTable<Test2>();
3 years ago
//用例代码
db.Insertable(new Test2() { p = "1" }).ExecuteCommand();//用例代码
db.Insertable(new Test2() { p = "2", delPer = 1 }).ExecuteCommand();//用例代码
var updateList = db.Queryable<Test2>()
.ToList();
db.Fastest<Test2>().BulkCopy(updateList);
int index = 0;
foreach (var update in updateList)
{
update.p = index.ToString();
index++;
}
db.Fastest<Test2>().BulkUpdate(updateList);
db.CodeFirst.InitTables<UnitTestoffset11>();
db.Fastest<UnitTestoffset11>().BulkCopy(new List<UnitTestoffset11>() {
new UnitTestoffset11 { },
new UnitTestoffset11 { DateTimeOffset= DateTimeOffset.Now}
});
var list = db.Queryable<UnitTestoffset11>().ToList();
3 years ago
Console.WriteLine("用例跑完");
}
public class UnitTestoffset11
{
[SugarColumn(IsNullable =true)]
public DateTimeOffset? DateTimeOffset { get; set; }
}
3 years ago
3 years ago
[SugarTable("UnitFastest0011a")]
3 years ago
public class Test2
{
3 years ago
[SugarColumn(IsNullable = false,IsIdentity =true, IsPrimaryKey = true)]
3 years ago
public int id { get; set; }
[SugarColumn(IsNullable = false)]
public string p { get; set; }
[SugarColumn(IsNullable = true)]
public int? delPer { get; set; }
[SugarColumn(IsNullable = true)]
public DateTime? del_Time { get; set; }
}
}
}