From 85cd1e9f1331fbb1c832eaa3d5fd75555f149f15 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 28 Oct 2022 12:41:47 +0800 Subject: [PATCH] Add unit test --- Src/Asp.Net/SqliteTest/SqliteTest.csproj | 1 + Src/Asp.Net/SqliteTest/UnitTest/Main.cs | 1 + .../SqliteTest/UnitTest/UnitNavInsertadfa1.cs | 217 ++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 Src/Asp.Net/SqliteTest/UnitTest/UnitNavInsertadfa1.cs diff --git a/Src/Asp.Net/SqliteTest/SqliteTest.csproj b/Src/Asp.Net/SqliteTest/SqliteTest.csproj index 94d0449b5..1e3cefb6c 100644 --- a/Src/Asp.Net/SqliteTest/SqliteTest.csproj +++ b/Src/Asp.Net/SqliteTest/SqliteTest.csproj @@ -77,6 +77,7 @@ + diff --git a/Src/Asp.Net/SqliteTest/UnitTest/Main.cs b/Src/Asp.Net/SqliteTest/UnitTest/Main.cs index 178236ef5..362620e82 100644 --- a/Src/Asp.Net/SqliteTest/UnitTest/Main.cs +++ b/Src/Asp.Net/SqliteTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UnitNavInsertadfa1.Init(); UnitNavInsertIssue.Init(); UnitInsertNavN.Init(); UNavTest.Init(); diff --git a/Src/Asp.Net/SqliteTest/UnitTest/UnitNavInsertadfa1.cs b/Src/Asp.Net/SqliteTest/UnitTest/UnitNavInsertadfa1.cs new file mode 100644 index 000000000..8b7c142da --- /dev/null +++ b/Src/Asp.Net/SqliteTest/UnitTest/UnitNavInsertadfa1.cs @@ -0,0 +1,217 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +namespace OrmTest +{ + public class UnitNavInsertadfa1 + { + public static void Init() + { + + //SQLiteConnection.CreateFile(Environment.CurrentDirectory + @"\Test.sqlite"); + + var db = new SqlSugarScope(new SqlSugar.ConnectionConfig() + { + ConnectionString = @"DataSource=" + Environment.CurrentDirectory + @"\Test1.sqlite", + DbType = DbType.Sqlite, + IsAutoCloseConnection = true + }); + + //建表 + + db.CodeFirst.InitTables(); + db.CodeFirst.InitTables(); + db.DbMaintenance.TruncateTable(); + db.DbMaintenance.TruncateTable(); + db.Insertable(new AssignMission() + { + Transporttask_NO = "a", + Carrier_Name = "a1" + }).ExecuteReturnEntity(); + db.Insertable(new AssignMissionDetail() + { + Transporttask_NO = "a", + Brand_No = "child1" + }).ExecuteReturnEntity(); + //用例代码 + List list = db.Queryable() + .Includes(it => it.detailList) + .ToList(); + foreach (var item in list) + { + item.id = item.id + 100; + } + bool b = db.InsertNav(list) + .Include(z1 => z1.detailList) + .ExecuteCommand(); + + } + + //建类 + [SugarTable("ti_assignmission1")] + public partial class AssignMission + { + public AssignMission() + { + + + } + + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int id { get; set; } + + /// + /// Desc:运输任务单号 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "transporttask_no", IsNullable = true)] + public string Transporttask_NO { get; set; } + + /// + /// Desc:承运商名称 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "carrier_name", IsNullable = true)] + public string Carrier_Name { get; set; } + + /// + /// Desc:车牌号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "truck_name", IsNullable = true)] + public string Truck_Name { get; set; } + + /// + /// Desc:驾驶员 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "driver_name", IsNullable = true)] + public string Driver_Name { get; set; } + + /// + /// Desc:装货地磅号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "wb_no", IsNullable = true)] + public string wbNO { get; set; } + + /// + /// Desc:变更类型(新增、删除、内容变更) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "change_type", IsNullable = true)] + public string changeType { get; set; } + + + [Navigate(NavigateType.OneToMany, nameof(AssignMissionDetail.Transporttask_NO), nameof(Transporttask_NO))] + public List detailList { get; set; } + + } + + + [SugarTable("ti_assignmission_detail1")] + public partial class AssignMissionDetail + { + public AssignMissionDetail() + { + + + } + + /// + /// Desc: + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int id { get; set; } + + /// + /// Desc:运输任务单号 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "transporttask_no", IsNullable = true)] + public string Transporttask_NO { get; set; } + + /// + /// Desc:销售订单号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "order_no", IsNullable = true)] + public string Order_No { get; set; } + + /// + /// Desc:交货单号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "delivery_order_no", IsNullable = true)] + public string Delivery_Order_No { get; set; } + + /// + /// Desc:交货单行号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "ap_rowno", IsNullable = true)] + public string Sap_Rownos { get; set; } + + /// + /// Desc:批次 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "batch", IsNullable = true)] + public string Batch { get; set; } + + /// + /// Desc:品名 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "product_name", IsNullable = true)] + public string Product_Name { get; set; } + + /// + /// Desc:牌号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "brand_no", IsNullable = true)] + public string Brand_No { get; set; } + + /// + /// Desc:IC卡号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "ic_cardid", IsNullable = true)] + public string IC_Cardid { get; set; } + + /// + /// Desc:变更类型(新增、删除、内容变更) + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "change_type", IsNullable = true)] + public string changeType { get; set; } + + } + } +}