SqlSugar/Src/Asp.Net/OracleTest/UnitTest/UInsert3.cs
2023-11-10 21:24:22 +08:00

114 lines
3.4 KiB
C#

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
internal class UInsert3
{
public static void Init()
{
var db = NewUnitTest.Db;
db.Insertable(new Order() { Name = "a" }).ExecuteCommand();
db.Insertable(new List<Order>() {
new Order() { Name = "a" },
new Order() { Name = "a" }
}).ExecuteCommand();
db.Insertable(new ORDER() { Name = "a" }).ExecuteCommand();
db.Updateable(new Order()
{
CustomId = 1,
CreateTime = DateTime.Now,
Id = 1,
Price = 1,
Name = "a"
}).ExecuteCommand();
db.Updateable(new List<Order>(){ new Order()
{
CustomId = 1,
CreateTime = DateTime.Now,
Id = 1,
Price = 1,
Name = "a"
},
new Order()
{
CustomId = 1,
CreateTime = DateTime.Now,
Id = 1,
Price = 1,
Name = "a"
} }).ExecuteCommand();
db.Updateable<Order>().SetColumns(it => new Order()
{
CustomId = 1,
Price = 1,
Name = "a"
}, true).Where(it => it.Id == 1).ExecuteCommand();
db.Updateable<ORDER>().SetColumns(it => new ORDER()
{
CustomId = 1,
Price = 1,
Name = "a"
}, true).Where(it => it.Id == 1).ExecuteCommand();
db.CodeFirst.InitTables<Unitdfafaadfaa>();
List<Unitdfafaadfaa> result = new List<Unitdfafaadfaa>();
for (int i = 0; i < 4000; i++)
{
result.Add(new Unitdfafaadfaa() { Id=i, Name="a" });
}
db.Insertable(result).ExecuteCommand();
db.DbMaintenance.TruncateTable<Unitdfafaadfaa>();
}
public class Unitdfafaadfaa
{
[SugarColumn(IsPrimaryKey =true)]
public long Id { get; set; }
public string Name { get; set; }
}
public class Order
{
[SugarColumn(IsPrimaryKey = true,OracleSequenceName = "Seq_Id")]
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
public decimal Price { get; set; }
[SugarColumn(InsertServerTime =true,UpdateServerTime =true)]
public DateTime CreateTime { get; set; }
[SugarColumn(IsNullable = true)]
public int CustomId { get; set; }
}
public class ORDER
{
[SugarColumn(IsPrimaryKey = true, OracleSequenceName = "Seq_Id")]
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
public decimal Price { get; set; }
[SugarColumn(InsertSql = "sysdate", UpdateSql = "sysdate")]
public DateTime CreateTime { get; set; }
[SugarColumn(IsNullable = true)]
public int CustomId { get; set; }
}
}
}