diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs index d9cabba6c..6208daa2f 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Main.cs @@ -33,6 +33,7 @@ namespace OrmTest } public static void Init() { + Unitdsfsssysf.Init(); Unitsdfadysssdf.Init(); UnitOneToMany123131.Init(); Unitadfasdys.Init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdsfsssysf.cs b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdsfsssysf.cs new file mode 100644 index 000000000..1e369be86 --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UserTestCases/UnitTest/Unitdsfsssysf.cs @@ -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(); + 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; } + } + } +}