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
25 KiB
JavaScript
1 line
25 KiB
JavaScript
12 months ago
|
"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[1327],{5318:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>c,toc:()=>d});var r=s(5893),t=s(1151),i=s(510);const o={id:"dbcontext-add",title:"9.6 \u65b0\u589e\u64cd\u4f5c",sidebar_label:"9.6 \u65b0\u589e\u64cd\u4f5c"},l=void 0,c={id:"dbcontext-add",title:"9.6 \u65b0\u589e\u64cd\u4f5c",description:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7",source:"@site/docs/dbcontext-add.mdx",sourceDirName:".",slug:"/dbcontext-add",permalink:"/docs/dbcontext-add",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/dbcontext-add.mdx",tags:[],version:"current",lastUpdatedBy:"MonkSoul",lastUpdatedAt:1682389320,formattedLastUpdatedAt:"Apr 25, 2023",frontMatter:{id:"dbcontext-add",title:"9.6 \u65b0\u589e\u64cd\u4f5c",sidebar_label:"9.6 \u65b0\u589e\u64cd\u4f5c"},sidebar:"docs",previous:{title:"9.5 \u4ed3\u50a8\u6a21\u5f0f (Repository)",permalink:"/docs/dbcontext-repository"},next:{title:"9.7 \u66f4\u65b0\u64cd\u4f5c",permalink:"/docs/dbcontext-update"}},a={},d=[{value:"9.6.1 \u65b0\u589e\u4e00\u6761\uff0c\u65e0\u8fd4\u56de\u503c",id:"961-\u65b0\u589e\u4e00\u6761\u65e0\u8fd4\u56de\u503c",level:2},{value:"9.6.2 \u65b0\u589e\u4e00\u6761\uff0c\u8fd4\u56de\u6700\u65b0\u6570\u636e",id:"962-\u65b0\u589e\u4e00\u6761\u8fd4\u56de\u6700\u65b0\u6570\u636e",level:2},{value:"9.6.3 \u65b0\u589e\u591a\u6761\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09",id:"963-\u65b0\u589e\u591a\u6761\u4e0d\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.6.4 \u65b0\u589e\u591a\u6761\uff08\u7acb\u5373\u63d0\u4ea4\uff09",id:"964-\u65b0\u589e\u591a\u6761\u7acb\u5373\u63d0\u4ea4",level:2},{value:"9.6.5 \u5ffd\u7565\u7a7a\u503c\u65b0\u589e",id:"965-\u5ffd\u7565\u7a7a\u503c\u65b0\u589e",level:2},{value:"9.6.6 \u8868\u5e26\u89e6\u53d1\u5668\u5f02\u5e38\u89e3\u51b3",id:"966-\u8868\u5e26\u89e6\u53d1\u5668\u5f02\u5e38\u89e3\u51b3",level:2},{value:"9.6.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"967-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.a)(),...e.components},{Details:s}=n;return s||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s,{children:[(0,r.jsx)("summary",{children:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7"}),(0,r.jsx)("div",{children:(0,r.jsx)("div",{children:(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"\u95ee\u9898\u4fee\u590d"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\xa0",(0,r.jsx)(i.Z,{children:"\u4fee\u590d"})," \u5b9e\u4f53\u62d3\u5c55\u65b9\u5f0f\u64cd\u4f5c\u6570\u636e\u5e93\u51fa\u73b0\u7a7a\u5f02\u5e38\u95ee\u9898 ",(0,r.jsx)("sup",{children:"4.8.5"})," ",(0,r.jsx)("sup",{children:"\u23f1\ufe0f2023.01.28"})," ",(0,r.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I6AXU6",children:"#I6AXU6"})]}),"\n"]}),"\n"]}),"\n"]})})})]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u63d0\u4f9b\u975e\u5e38\u591a\u7684\u8bed\u6cd5\u7cd6\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"961-\u65b0\u589e\u4e00\u6761\u65e0\u8fd4\u56de\u503c",children:"9.6.1 \u65b0\u589e\u4e00\u6761\uff0c\u65e0\u8fd4\u56de\u503c"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'var user = new User { Name = "\u767e\u5c0f\u50e7", Age = 27 };\r\n\r\n// ==== \u540c\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nrepository.Insert(user);\r\n\r\n// \u793a\u4f8b\u4e8c\r\nuser.Insert();\r\n\r\n// \u793a\u4f8b\u4e09\r\nrepository.Entities.Add(user);\r\n\r\n// \u793a\u4f8b\u56db\r\nrepository.ChangeEntityState(user, EntityState.Added);\r\n\r\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\r\n\r\n// \u793a\u4f8b\u4e00\r\nawait r
|