SqlSugar/Src/Asp.Net/OracleTest/UnitTest/UnitStorageableBool.cs
2022-08-05 19:10:33 +08:00

42 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using SqlSugar;
namespace OrmTest
{
public class UnitStorageableBool
{
public static void Init()
{
var db = NewUnitTest.Db;
//建表
if (!db.DbMaintenance.IsAnyTable("Test0011", false))
{
db.CodeFirst.InitTables<Test001>();
}
db.Aop.OnError = (exp) =>//SQL报错
{
//Console.WriteLine($"SqlSugar[Error]{UtilMethods.GetSqlString(DbType.SqlServer, exp.Sql, exp.Parametres)}" + Environment.NewLine);
};
//用例代码
var result = db.Insertable(new Test001() { id = true }).ExecuteCommand();//用例代码
var result1 = db.Insertable(new Test001() { id = false }).ExecuteCommand();//用例代码
var res = db.Storageable(new Test001() { id1 = false, id = false }).WhereColumns(x => x.id1)
.SplitUpdate(x => x.Any()).ToStorage();
res.AsUpdateable.ExecuteCommand();
//Console.WriteLine(result);
//Console.WriteLine("用例跑完");
// Console.ReadKey();
}
//建类
[SugarTable("Test0011")]
public class Test001
{
[SugarColumn(ColumnDataType = "NUMBER(1)", SqlParameterDbType = System.Data.DbType.Int16)]
public bool id { get; set; }
[SugarColumn(ColumnDataType = "NUMBER(1)", SqlParameterDbType = System.Data.DbType.Int16)]
public bool id1 { get; set; }
}
}
}