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(); db.DbMaintenance.TruncateTable(); db.Insertable(new Products() { BusinessSliceID = 1, Id = 1, ItemName = "a" }).ExecuteCommand(); var cargolaneDbs = db.Queryable() .Select(it => new { name=it.ItemName, newit=it, }) .ToList(); if (cargolaneDbs.FirstOrDefault().newit.ItemName != "a") { throw new Exception("unit error"); } var cargolaneDbs2 = db.Queryable() .Select(it => new { name = it.ItemName, it, }) .ToList(); if (cargolaneDbs2.FirstOrDefault().it.ItemName != "a") { throw new Exception("unit error"); } } [SugarTable("Unitpsroducsfdsatsfd")] public class Products { /// /// 产品 Id /// [SugarColumn(IsPrimaryKey = true)] public int Id { get; set; } /// /// 物品名称 /// public string ItemName { get; set; } /// /// 关联商品id /// public int BusinessSliceID { get; set; } /// /// 关联商品数据 /// [Navigate(NavigateType.OneToOne, nameof(BusinessSliceID), nameof(Id))] public Products? SliceProduct { get; set; } } } }