You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[2710],{9801:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>l,toc:()=>d});var t=r(5893),s=r(1151);const i={id:"dbcontext-delete",title:"9.9 \u5220\u9664\u64cd\u4f5c",sidebar_label:"9.9 \u5220\u9664\u64cd\u4f5c"},o=void 0,l={id:"dbcontext-delete",title:"9.9 \u5220\u9664\u64cd\u4f5c",description:"\u4ee5\u4e0b\u5185\u5bb9\u5305\u542b Exists \u5355\u8bcd\u7684\u5728 Furion 2.6.0 + \u7248\u672c\u4e2d\u5df2\u79fb\u9664\u3002",source:"@site/docs/dbcontext-delete.mdx",sourceDirName:".",slug:"/dbcontext-delete",permalink:"/docs/dbcontext-delete",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/dbcontext-delete.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1700736899,formattedLastUpdatedAt:"Nov 23, 2023",frontMatter:{id:"dbcontext-delete",title:"9.9 \u5220\u9664\u64cd\u4f5c",sidebar_label:"9.9 \u5220\u9664\u64cd\u4f5c"},sidebar:"docs",previous:{title:"9.8 \u65b0\u589e\u6216\u66f4\u65b0\u64cd\u4f5c",permalink:"/docs/dbcontext-add-or-update"},next:{title:"9.10 \u6279\u91cf\u64cd\u4f5c",permalink:"/docs/dbcontext-batch"}},a={},d=[{value:"9.9.1 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09",id:"991-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\u4e0d\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.9.2 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u7acb\u5373\u63d0\u4ea4\uff09",id:"992-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.9.3 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09",id:"993-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\u4e0d\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.9.4 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09",id:"994-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.9.5 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09",id:"995-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\u4e0d\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.9.6 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u7acb\u5373\u63d0\u4ea4\uff09",id:"996-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.9.7 \u5047\u5220\u9664/\u8f6f\u5220\u9664",id:"997-\u5047\u5220\u9664\u8f6f\u5220\u9664",level:2},{value:"9.9.7.1 \u6dfb\u52a0 <code>[FakeDelete]</code> \u6807\u8bb0",id:"9971-\u6dfb\u52a0-fakedelete-\u6807\u8bb0",level:3},{value:"9.9.7.2 \u5047\u5220\u9664\u4f7f\u7528",id:"9972-\u5047\u5220\u9664\u4f7f\u7528",level:3},{value:"9.9.8 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"998-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function c(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,s.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.admonition,{title:"\u529f\u80fd\u79fb\u9664\u58f0\u660e",type:"warning",children:(0,t.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u5305\u542b ",(0,t.jsx)(n.code,{children:"Exists"})," \u5355\u8bcd\u7684\u5728 ",(0,t.jsx)(n.code,{children:"Furion 2.6.0 +"})," \u7248\u672c\u4e2d\u5df2\u79fb\u9664\u3002"]})}),"\n",(0,t.jsx)(n.h2,{id:"991-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\u4e0d\u7acb\u5373\u63d0\u4ea4",children:"9.9.1 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.Delete(user);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.Delete();\r\n\r\n// \u793a\u4f8b\u4e09\r\nrepository.ChangeEntityState(user, EntityState.Deleted);\r\n\r\n// \u793a\u4f8b\u56db\r\nrepository.Entities.Remove(user);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.DeleteAsync(user);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait user.DeleteAsync();\n"})}),"\n",(0,t.jsx)(n.h2,{id:"992-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\u7acb\u5373\u63d0\u4ea4",children:"9.9.2 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u7acb\u5373\u63d0\u4ea4\uff09"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.DeleteNow(user);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.DeleteNow();\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.DeleteNowAsync(user);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait user.DeleteNowAsync();\n"})}),"\n",(0,t.jsx)(n.h2,{id:"993-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\u4e0d\u7acb\u5373\u63d0\u4ea4",children:"9.9.3 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.Delete(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.Delete(1);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.DeleteAsync(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait user.DeleteAsync(1);\n"})}),"\n",(0,t.jsx)(n.h2,{id:"994-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\u7acb\u5373\u63d0\u4ea4",children:"9.9.4 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.DeleteNow(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.DeleteNow(1);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.DeleteNowAsync(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait user.DeleteNowAsync(1);\n"})}),"\n",(0,t.jsx)(n.h2,{id:"995-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\u4e0d\u7acb\u5373\u63d0\u4ea4",children:"9.9.5 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"}),"\n",(0,t.jsx)(n.admonition,{title:"\u529f\u80fd\u79fb\u9664\u58f0\u660e",type:"caution",children:(0,t.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u5df2\u5728 ",(0,t.jsx)(n.code,{children:"Furion 2.6.0 +"})," \u7248\u672c\u79fb\u9664\u3002"]})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.DeleteExists(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.DeleteExists(1);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.DeleteExistsAsync(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait user.DeleteExistsAsync(1);\n"})}),"\n",(0,t.jsx)(n.h2,{id:"996-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\u7acb\u5373\u63d0\u4ea4",children:"9.9.6 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u7acb\u5373\u63d0\u4ea4\uff09"}),"\n",(0,t.jsx)(n.admonition,{title:"\u529f\u80fd\u79fb\u9664\u58f0\u660e",type:"caution",children:(0,t.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u5df2\u5728 ",(0,t.jsx)(n.code,{children:"Furion 2.6.0 +"})," \u7248\u672c\u79fb\u9664\u3002"]})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.DeleteExistsNow(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.DeleteExistsNow(1);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.DeleteExistsNowAsync(1);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait user.DeleteExistsNowAsync(1);\n"})}),"\n",(0,t.jsx)(n.admonition,{title:"\u5c0f\u77e5\u8bc6",type:"tip",children:(0,t.jsxs)(n.p,{children:["\u6240\u6709\u5e26 ",(0,t.jsx)(n.code,{children:"Now"})," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",(0,t.jsx)(n.code,{children:"SaveChanges"})," \u6216 ",(0,t.jsx)(n.code,{children:"SaveChangesAsync"}),"\u3002"]})}),"\n",(0,t.jsx)(n.h2,{id:"997-\u5047\u5220\u9664\u8f6f\u5220\u9664",children:"9.9.7 \u5047\u5220\u9664/\u8f6f\u5220\u9664"}),"\n",(0,t.jsx)(n.admonition,{title:"\u529f\u80fd\u79fb\u9664\u58f0\u660e",type:"warning",children:(0,t.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u5728 ",(0,t.jsx)(n.code,{children:"Furion 2.10 +"})," \u7248\u672c\u4e2d\u5df2\u79fb\u9664\u3002"]})}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u4e2d\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(n.code,{children:"[FakeDelete]"})," \u7279\u6027\u6807\u8bb0\u5047\u5220\u9664\u7279\u6027\uff0c\u5982\uff1a"]}),"\n",(0,t.jsxs)(n.h3,{id:"9971-\u6dfb\u52a0-fakedelete-\u6807\u8bb0",children:["9.9.7.1 \u6dfb\u52a0 ",(0,t.jsx)(n.code,{children:"[FakeDelete]"})," \u6807\u8bb0"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {3}",children:"public class Model: IEntity\r\n{\r\n [FakeDelete(true)] // \u8bbe\u7f6e\u5047\u5220\u9664\u7684\u503c\r\n public bool IsDeleted { get; set; }\r\n}\n"})}),"\n",(0,t.jsx)(n.admonition,{title:"[FakeDelete]",type:"note",children:(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"[FakeDelete]"})," \u5c5e\u6027\u62e5\u6709\u5e26\u4e00\u4e2a\u53c2\u6570\u7684\u6784\u9020\u51fd\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u5047\u5220\u9664\u7684\u503c"]})}),"\n",(0,t.jsx)(n.h3,{id:"9972-\u5047\u5220\u9664\u4f7f\u7528",children:"9.9.7.2 \u5047\u5220\u9664\u4f7f\u7528"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.FakeDelete(entity);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nrepository.FakeDeleteNow(entity);\r\n\r\n// \u793a\u4f8b\u4e09\r\nrepository.FakeDelete(1);\r\n\r\n// \u793a\u4f8b\u56db\r\nrepository.FakeDeleteNow(1);\r\n\r\n// \u793a\u4f8b\u4e94\r\nentity.FakeDelete();\r\n\r\n// \u793a\u4f8b\u516d\r\nrepository.UpdateInclude(user, u => u.IsDeleted);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait repository.FakeDeleteAsync(entity);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nawait repository.FakeDeleteNowAsync(entity);\r\n\r\n// \u793a\u4f8b\u4e09\r\nawait repository.FakeDeleteAsync(1);\r\n\r\n// \u793a\u4f8b\u56db\r\nawait repository.FakeDeleteNowAsync(1);\r\n\r\n// \u793a\u4f8b\u4e94\r\nawait entity.FakeDeleteAsync();\r\n\r\n// \u793a\u4f8b\u516d\r\nawait repository.UpdateIncludeAsync(user, u => u.IsDeleted);\n"})}),"\n",(0,t.jsx)(n.h2,{id:"998-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"9.9.8 \u53cd\u9988\u4e0e\u5efa\u8bae"}),"\n",(0,t.jsx)(n.admonition,{title:"\u4e0e\u6211\u4eec\u4ea4\u6d41",type:"note",children:(0,t.jsxs)(n.p,{children:["\u7ed9 Furion \u63d0 ",(0,t.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/new?issue",children:"Issue"}),"\u3002"]})})]})}function u(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},1151:(e,n,r)=>{r.d(n,{Z:()=>l,a:()=>o});var t=r(7294);const s={},i=t.createContext(s);function o(e){const n=t.useContext(i);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),t.createElement(i.Provider,{value:n},e.children)}}}]); |