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.

46 lines
1.4 KiB

using OrmTest.UnitTest.Models;
using SqlSugar;
3 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom05
{
public static void Init()
{
3 years ago
var db = NewUnitTest.Db;
var id=db.Insertable(new Order() { CreateTime = DateTime.Now, Name = "a", Price =Convert.ToDecimal( 111.00) , CustomId = 1 }).ExecuteReturnIdentity();
3 years ago
var data = db.GetSimpleClient<Order>().GetById(id);
var x=db.Storageable(data).WhereColumns(it=>it.Price).ToStorage();
Check.Exception(x.UpdateList.Count == 0, "unit error");
db.CodeFirst.InitTables<MYOrder>();//建表
List<MYOrder> orders = new List<MYOrder>
{
new MYOrder
{
Name = "123",
Price =Convert.ToDecimal(10)
}
};
var x1 = db.Storageable(orders).WhereColumns(m => m.Price).ToStorage();
Console.WriteLine("insert:" + x1.InsertList.Count);
Console.WriteLine("update:" + x1.UpdateList.Count);
Console.WriteLine("------------");
x1.AsInsertable.ExecuteCommand();
Check.Exception( x1.AsUpdateable.ExecuteCommand()==0,"unit errors");
3 years ago
}
}
}