From 2addf2263ae0da24ac5a58e852f684675aca2386 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Mon, 30 Sep 2019 01:03:45 +0800 Subject: [PATCH] update --- 联级保存.md | 92 ++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/联级保存.md b/联级保存.md index a64ba51..c101dc5 100644 --- a/联级保存.md +++ b/联级保存.md @@ -43,54 +43,54 @@ class CagetoryParent [Fact] public void EnableAddOrUpdateNavigateList_OneToMany_Parent() { - var repo = g.sqlite.GetRepository(); - var cts = new[] { - new CagetoryParent +var repo = g.sqlite.GetRepository(); +var cts = new[] { + new CagetoryParent + { + Name = "分类1", + Childs = new List(new[] { - Name = "分类1", - Childs = new List(new[] - { - new CagetoryParent { Name = "分类1_1" }, - new CagetoryParent { Name = "分类1_2" }, - new CagetoryParent { Name = "分类1_3" } - }) - }, - new CagetoryParent + new CagetoryParent { Name = "分类1_1" }, + new CagetoryParent { Name = "分类1_2" }, + new CagetoryParent { Name = "分类1_3" } + }) + }, + new CagetoryParent + { + Name = "分类2", + Childs = new List(new[] { - Name = "分类2", - Childs = new List(new[] - { - new CagetoryParent { Name = "分类2_1" }, - new CagetoryParent { Name = "分类2_2" } - }) - } - }; - repo.Insert(cts); - //执行创建表,和插入数据: - //INSERT INTO "EAUNL_OTMP_CT"("Id", "Name", "ParentId") VALUES('5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f', '分类1', '00000000-0000-0000-0000-000000000000'), ('5d90afcb-ed57-f6f4-0082-cb6c5b531b3e', '分类2', '00000000-0000-0000-0000-000000000000') - //INSERT INTO "EAUNL_OTMP_CT"("Id", "Name", "ParentId") VALUES('5d90afcb-ed57-f6f4-0082-cb6d0c1c5f1a', '分类1_1', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afcb-ed57-f6f4-0082-cb6e74bd8eef', '分类1_2', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afcb-ed57-f6f4-0082-cb6f6267cc5f', '分类1_3', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afcb-ed57-f6f4-0082-cb7057c41d46', '分类2_1', '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e'), ('5d90afcb-ed57-f6f4-0082-cb7156e0375e', '分类2_2', '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e') - cts[0].Name = "分类11"; - cts[0].Childs.Clear(); - cts[1].Name = "分类22"; - cts[1].Childs.Clear(); - repo.Update(cts); - //UPDATE "EAUNL_OTMP_CT" SET "Name" = CASE "Id" - //WHEN '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f' THEN '分类11' - //WHEN '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e' THEN '分类22' END - //WHERE ("Id" IN ('5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f','5d90afcb-ed57-f6f4-0082-cb6c5b531b3e')) - //Goodss.Clear 后没有执行删除子集合操作,说明没有做完整的对比 - cts[0].Name = "分类111"; - cts[0].Childs.Clear(); - cts[0].Childs.Add(new CagetoryParent { Name = "分类1_33" }); - cts[1].Name = "分类222"; - cts[1].Childs.Clear(); - cts[1].Childs.Add(new CagetoryParent { Name = "分类2_22" }); - repo.Update(cts); - //UPDATE "EAUNL_OTMP_CT" SET "Name" = CASE "Id" - //WHEN '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f' THEN '分类111' - //WHEN '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e' THEN '分类222' END - //WHERE ("Id" IN ('5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f','5d90afcb-ed57-f6f4-0082-cb6c5b531b3e')) - //INSERT INTO "EAUNL_OTMP_CT"("Id", "Name", "ParentId") VALUES('5d90afe8-ed57-f6f4-0082-cb725df546ea', '分类1_33', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afe8-ed57-f6f4-0082-cb7338a6214c', '分类2_22', '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e') + new CagetoryParent { Name = "分类2_1" }, + new CagetoryParent { Name = "分类2_2" } + }) + } +}; +repo.Insert(cts); +//执行创建表,和插入数据: +//INSERT INTO "EAUNL_OTMP_CT"("Id", "Name", "ParentId") VALUES('5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f', '分类1', '00000000-0000-0000-0000-000000000000'), ('5d90afcb-ed57-f6f4-0082-cb6c5b531b3e', '分类2', '00000000-0000-0000-0000-000000000000') +//INSERT INTO "EAUNL_OTMP_CT"("Id", "Name", "ParentId") VALUES('5d90afcb-ed57-f6f4-0082-cb6d0c1c5f1a', '分类1_1', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afcb-ed57-f6f4-0082-cb6e74bd8eef', '分类1_2', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afcb-ed57-f6f4-0082-cb6f6267cc5f', '分类1_3', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afcb-ed57-f6f4-0082-cb7057c41d46', '分类2_1', '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e'), ('5d90afcb-ed57-f6f4-0082-cb7156e0375e', '分类2_2', '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e') +cts[0].Name = "分类11"; +cts[0].Childs.Clear(); +cts[1].Name = "分类22"; +cts[1].Childs.Clear(); +repo.Update(cts); +//UPDATE "EAUNL_OTMP_CT" SET "Name" = CASE "Id" +//WHEN '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f' THEN '分类11' +//WHEN '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e' THEN '分类22' END +//WHERE ("Id" IN ('5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f','5d90afcb-ed57-f6f4-0082-cb6c5b531b3e')) +//Childs.Clear 后没有执行删除子集合操作,说明没有做完整的对比 +cts[0].Name = "分类111"; +cts[0].Childs.Clear(); +cts[0].Childs.Add(new CagetoryParent { Name = "分类1_33" }); +cts[1].Name = "分类222"; +cts[1].Childs.Clear(); +cts[1].Childs.Add(new CagetoryParent { Name = "分类2_22" }); +repo.Update(cts); +//UPDATE "EAUNL_OTMP_CT" SET "Name" = CASE "Id" +//WHEN '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f' THEN '分类111' +//WHEN '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e' THEN '分类222' END +//WHERE ("Id" IN ('5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f','5d90afcb-ed57-f6f4-0082-cb6c5b531b3e')) +//INSERT INTO "EAUNL_OTMP_CT"("Id", "Name", "ParentId") VALUES('5d90afe8-ed57-f6f4-0082-cb725df546ea', '分类1_33', '5d90afcb-ed57-f6f4-0082-cb6b78eaaf9f'), ('5d90afe8-ed57-f6f4-0082-cb7338a6214c', '分类2_22', '5d90afcb-ed57-f6f4-0082-cb6c5b531b3e') } ```