Add user test case

This commit is contained in:
sunkaixuan 2024-04-26 17:50:01 +08:00
parent da7c853093
commit 5040c63c1d
2 changed files with 82 additions and 0 deletions

View File

@ -32,6 +32,7 @@ namespace OrmTest
}
public static void Init()
{
Unitadfafafa.Init();
UnitSubGroupadfa.Init();
UnitAsyncToken.Init();
UnitSplitadfa.Init();

View File

@ -0,0 +1,81 @@
using System;
using System.Reflection;
using System.Threading.Tasks;
using SqliteTest.UnitTest;
using SqlSugar;
namespace OrmTest
{
public class Unitadfafafa
{
public static void Init()
{
ISqlSugarClient db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.Sqlite,
IsAutoCloseConnection = true,
ConfigureExternalServices = new ConfigureExternalServices
{
EntityService = (c, p) =>
{
if (new NullabilityInfoContext()
.Create(c).WriteState is NullabilityState.Nullable)
{
p.IsNullable = true;
}
}
},
}, db =>
{
//db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前
//{
// var str = UtilMethods.GetSqlString(DbType.MySql, sql, pars);
// Console.WriteLine("===");
// Console.WriteLine(str);
// Console.WriteLine("===");
//};
});
db.CodeFirst.InitTables<Test003>();
var res2 = db.Insertable<Test003>(new Test003() { OVOV = new ObjctValueTest { Code333 = "11", Code4444 = "333" } }).ExecuteCommand();
var res = db.Queryable<Test003>().Any(x => true);
}
[SugarTable("Test003")]
//建类
public class Test003
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; } = Guid.NewGuid();
public DateTime? CreateTime { get; set; } = DateTime.Now;
public string? Code { get; set; }
[SqlSugar.SugarColumn(IsOwnsOne = true)]
public ObjctValueTest OVOV { get; set; }
}
public class ObjctValueTest
{
public string Code4444 { get; set; }
public string Code333 { get; set; }
}
}
}