Add user test case

This commit is contained in:
sunkaixuan 2025-05-26 13:41:29 +08:00
parent 68f187fd82
commit 7295341ac0
2 changed files with 71 additions and 0 deletions

View File

@ -33,6 +33,7 @@ namespace OrmTest
} }
public static void Init() public static void Init()
{ {
Unitdsfsssysf.Init();
Unitsdfadysssdf.Init(); Unitsdfadysssdf.Init();
UnitOneToMany123131.Init(); UnitOneToMany123131.Init();
Unitadfasdys.Init(); Unitadfasdys.Init();

View File

@ -0,0 +1,70 @@
using SQLitePCL;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class Unitdsfsssysf
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CodeFirst.InitTables<Products>();
db.DbMaintenance.TruncateTable<Products>();
db.Insertable(new Products() { BusinessSliceID = 1, Id = 1, ItemName = "a" }).ExecuteCommand();
var cargolaneDbs = db.Queryable<Products>()
.Select(it => new
{
name=it.ItemName,
newit=it,
})
.ToList();
if (cargolaneDbs.FirstOrDefault().newit.ItemName != "a")
{
throw new Exception("unit error");
}
var cargolaneDbs2 = db.Queryable<Products>()
.Select(it => new
{
name = it.ItemName,
it,
})
.ToList();
if (cargolaneDbs2.FirstOrDefault().it.ItemName != "a")
{
throw new Exception("unit error");
}
}
[SugarTable("Unitpsroducsfdsatsfd")]
public class Products
{
/// <summary>
/// 产品 Id
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public int Id { get; set; }
/// <summary>
/// 物品名称
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 关联商品id
/// </summary>
public int BusinessSliceID { get; set; }
/// <summary>
/// 关联商品数据
/// </summary>
[Navigate(NavigateType.OneToOne, nameof(BusinessSliceID), nameof(Id))]
public Products? SliceProduct { get; set; }
}
}
}