"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[1862],{5855:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>l,default:()=>u,frontMatter:()=>i,metadata:()=>d,toc:()=>c});var t=r(5893),s=r(1151);const i={id:"sqlsugar-old",title:"10.1. SqlSugar \u96c6\u6210",sidebar_label:"10.1. SqlSugar \u96c6\u6210"},l=void 0,d={id:"sqlsugar-old",title:"10.1. SqlSugar \u96c6\u6210",description:"\u5728 Furion \u5305\u4e2d\u9ed8\u8ba4\u96c6\u6210\u4e86 EFCore\uff0c\u5982\u679c\u4e0d\u4f7f\u7528 EFCore\uff0c\u53ef\u5b89\u88c5\u7eaf\u51c0\u7248 Furion.Pure \u4ee3\u66ff Furion\uff0c\u8fd9\u6837\u53ef\u4ee5\u5ffd\u7565\u672c\u7ae0\u8282\u76f4\u63a5\u6309\u7167 SqlSugar \u5b98\u65b9\u6587\u6863\u4f7f\u7528\u3002",source:"@site/docs/sqlsugar-old.mdx",sourceDirName:".",slug:"/sqlsugar-old",permalink:"/docs/sqlsugar-old",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/sqlsugar-old.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1698699579,formattedLastUpdatedAt:"Oct 30, 2023",frontMatter:{id:"sqlsugar-old",title:"10.1. SqlSugar \u96c6\u6210",sidebar_label:"10.1. SqlSugar \u96c6\u6210"}},a={},c=[{value:"10.1.1 \u5173\u4e8e SqlSugar",id:"1011-\u5173\u4e8e-sqlsugar",level:2},{value:"10.1.2 \u5982\u4f55\u96c6\u6210",id:"1012-\u5982\u4f55\u96c6\u6210",level:2},{value:"10.1.2.1 \u6ce8\u518c SqlSugar
\u670d\u52a1",id:"10121-\u6ce8\u518c-sqlsugar-\u670d\u52a1",level:3},{value:"10.1.3 \u57fa\u672c\u4f7f\u7528",id:"1013-\u57fa\u672c\u4f7f\u7528",level:2},{value:"10.1.4 \u6570\u636e\u5e93\u64cd\u4f5c\u793a\u4f8b",id:"1014-\u6570\u636e\u5e93\u64cd\u4f5c\u793a\u4f8b",level:2},{value:"10.1.5 SqlSugarClient \u64cd\u4f5c\u793a\u4f8b",id:"1015-sqlsugarclient-\u64cd\u4f5c\u793a\u4f8b",level:2},{value:"10.1.5.1 \u57fa\u7840\u67e5\u8be2",id:"10151-\u57fa\u7840\u67e5\u8be2",level:3},{value:"10.1.5.2 \u8054\u8868\u67e5\u8be2",id:"10152-\u8054\u8868\u67e5\u8be2",level:3},{value:"10.1.5.3 \u5206\u9875\u67e5\u8be2",id:"10153-\u5206\u9875\u67e5\u8be2",level:3},{value:"10.1.5.4 \u63d2\u5165",id:"10154-\u63d2\u5165",level:3},{value:"10.1.5.5 \u66f4\u65b0",id:"10155-\u66f4\u65b0",level:3},{value:"10.1.5.6 \u5220\u9664",id:"10156-\u5220\u9664",level:3},{value:"10.1.6 Sql \u67e5\u8be2",id:"1016-sql-\u67e5\u8be2",level:2},{value:"10.1.7 \u6253\u5370 sql
\u5230 Swagger
",id:"1017-\u6253\u5370-sql-\u5230-swagger",level:2},{value:"10.1.8 Oracle
\u6ce8\u610f\u4e8b\u9879",id:"1018-oracle\u6ce8\u610f\u4e8b\u9879",level:2},{value:"10.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"1019-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function o(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.admonition,{title:"\u6e29\u99a8\u63d0\u9192",type:"warning",children:(0,t.jsxs)(n.p,{children:["\u5728 ",(0,t.jsx)(n.code,{children:"Furion"})," \u5305\u4e2d\u9ed8\u8ba4\u96c6\u6210\u4e86 ",(0,t.jsx)(n.code,{children:"EFCore"}),"\uff0c",(0,t.jsxs)(n.strong,{children:["\u5982\u679c\u4e0d\u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"EFCore"}),"\uff0c\u53ef\u5b89\u88c5\u7eaf\u51c0\u7248 ",(0,t.jsx)(n.code,{children:"Furion.Pure"})," \u4ee3\u66ff ",(0,t.jsx)(n.code,{children:"Furion"}),"\uff0c\u8fd9\u6837\u53ef\u4ee5\u5ffd\u7565\u672c\u7ae0\u8282\u76f4\u63a5\u6309\u7167 ",(0,t.jsx)(n.code,{children:"SqlSugar"})," \u5b98\u65b9\u6587\u6863\u4f7f\u7528"]}),"\u3002"]})}),"\n",(0,t.jsx)(n.h2,{id:"1011-\u5173\u4e8e-sqlsugar",children:"10.1.1 \u5173\u4e8e SqlSugar"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"SqlSugar"})," \u662f .NET/C# \u5e73\u53f0\u975e\u5e38\u4f18\u79c0\u7684 ",(0,t.jsx)(n.code,{children:"ORM"})," \u6846\u67b6\uff0c\u76ee\u524d ",(0,t.jsx)(n.code,{children:"NuGet"})," \u603b\u4e0b\u8f7d\u7a81\u7834 700K\uff0cGithub \u5173\u6ce8\u91cf\u4e5f\u9ad8\u8fbe 3.2K\uff0c\u662f\u76ee\u524d\u5f53\u4e4b\u65e0\u6127\u7684\u56fd\u4ea7\u4f18\u79c0 ORM \u6846\u67b6\u4e4b\u4e00\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"SqlSugar"})," \u5b98\u65b9\u5730\u5740\uff1a",(0,t.jsx)(n.a,{href:"http://www.donet5.com/",children:"http://www.donet5.com/"})]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"SqlSugar"})," \u4e0e EF \u4f18\u52bf\uff1a \u6027\u80fd\u6bd4 EF \u66f4\u5feb\u3001\u8bed\u6cd5\u4e0a\u624b\u66f4\u5bb9\u6613"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"SqlSugar"})," \u4e0e Dapper \u4f18\u52bf\uff1a SqlSugar \u529f\u80fd\u66f4\u52a0\u4e30\u5bcc\uff0c\u6027\u80fd\u4e1d\u6beb\u4e0d\u900a\u8272\u4e8e Dapper\uff0c\u5e76\u4e14\u6279\u91cf\u64cd\u4f5c\u6027\u80fd\u66f4\u597d"]}),"\n",(0,t.jsx)(n.h2,{id:"1012-\u5982\u4f55\u96c6\u6210",children:"10.1.2 \u5982\u4f55\u96c6\u6210"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 ",(0,t.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u4e2d\uff0c\u5df2\u7ecf\u63a8\u51fa ",(0,t.jsx)(n.code,{children:"SqlSugar"})," \u62d3\u5c55\u5305 ",(0,t.jsx)(n.a,{href:"https://www.nuget.org/packages/Furion.Extras.DatabaseAccessor.SqlSugar",children:"Furion.Extras.DatabaseAccessor.SqlSugar"}),"\u3002"]}),"\n",(0,t.jsxs)(n.h3,{id:"10121-\u6ce8\u518c-sqlsugar-\u670d\u52a1",children:["10.1.2.1 \u6ce8\u518c ",(0,t.jsx)(n.code,{children:"SqlSugar"})," \u670d\u52a1"]}),"\n",(0,t.jsxs)(n.p,{children:["\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728 ",(0,t.jsx)(n.code,{children:"Startup.cs"})," \u4e2d\u6dfb\u52a0 ",(0,t.jsx)(n.code,{children:"services.AddSqlSugar(config)"})," \u5373\u53ef\u3002\u5982\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// =====\u914d\u7f6e\u5355\u5e93=====\r\nservices.AddSqlSugar(new ConnectionConfig\r\n{\r\n ConnectionString = "Server=.xxxxx",//\u8fde\u63a5\u7b26\u5b57\u4e32\r\n DbType = DbType.SqlServer,\r\n IsAutoCloseConnection = true,\r\n InitKeyType = InitKeyType.Attribute//\u4ece\u7279\u6027\u8bfb\u53d6\u4e3b\u952e\u81ea\u589e\u4fe1\u606f\r\n});\r\n\r\n// =====\u914d\u7f6e\u591a\u5e93=====\r\nList connectConfigList = new List();\r\n//\u6570\u636e\u5e931\r\nconnectConfigList.Add(new ConnectionConfig\r\n{\r\n ConnectionString = "\u94fe\u63a5\u5b57\u7b26\u4e321",\r\n DbType = DbType.MySql,\r\n IsAutoCloseConnection = true,\r\n InitKeyType = InitKeyType.Attribute,\r\n ConfigId = "0",\r\n AopEvents = new AopEvents\r\n {\r\n //\u591a\u5e93\u72b6\u6001\u4e0b\u6bcf\u4e2a\u5e93\u5fc5\u987b\u5355\u72ec\u7ed1\u5b9a\u6253\u5370\u4e8b\u4ef6\uff0c\u5426\u5219\u53ea\u4f1a\u6253\u5370\u7b2c\u4e00\u4e2a\u5e93\u7684sql\u65e5\u5fd7\r\n OnLogExecuting = (sql, pars) =>\r\n {\r\n Console.WriteLine(SqlProfiler.ParameterFormat(sql, pars));\r\n Console.WriteLine();\r\n }\r\n }\r\n});\r\n//\u6570\u636e\u5e932\r\nconnectConfigList.Add(new ConnectionConfig\r\n{\r\n ConnectionString = "\u94fe\u63a5\u5b57\u7b26\u4e322",\r\n DbType = DbType.MySql,\r\n IsAutoCloseConnection = true,\r\n InitKeyType = InitKeyType.Attribute,\r\n ConfigId = "1",\r\n AopEvents = new AopEvents\r\n {\r\n //\u591a\u5e93\u72b6\u6001\u4e0b\u6bcf\u4e2a\u5e93\u5fc5\u987b\u5355\u72ec\u7ed1\u5b9a\u6253\u5370\u4e8b\u4ef6\uff0c\u5426\u5219\u53ea\u4f1a\u6253\u5370\u7b2c\u4e00\u4e2a\u5e93\u7684sql\u65e5\u5fd7\r\n OnLogExecuting = (sql, pars) =>\r\n {\r\n Console.WriteLine(SqlProfiler.ParameterFormat(sql, pars));\r\n Console.WriteLine();\r\n }\r\n }\r\n});\r\nservices.AddSqlSugar(connectConfigList.ToArray());\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u540c\u65f6\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u66f4\u591a\u914d\u7f6e\uff0c\u5982\uff1a\r\nps\uff1a\u591a\u5e93\u72b6\u6001\u4e0b\u6bcf\u4e2a\u5e93\u5fc5\u987b\u5355\u72ec\u7ed1\u5b9a\u6253\u5370\u4e8b\u4ef6\uff0c\u5426\u5219\u53ea\u4f1a\u6253\u5370\u7b2c\u4e00\u4e2a\u5e93\u7684 sql \u65e5\u5fd7\uff08\u53c2\u8003\u4e0a\u9762\u7684\u591a\u5e93\u914d\u7f6e\uff09"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'services.AddSqlSugar(connectConfigList.ToArray(),\r\ndb =>\r\n{\r\n //\u5904\u7406\u65e5\u5fd7\u4e8b\u52a1\r\n db.Aop.OnLogExecuting = (sql, pars) =>\r\n {\r\n Console.WriteLine(sql);\r\n Console.WriteLine(string.Join(",", pars?.Select(it => it.ParameterName + ":" + it.Value)));\r\n Console.WriteLine();\r\n App.PrintToMiniProfiler("SqlSugar", "Info", sql + "\\r\\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));\r\n };\r\n});\n'})}),"\n",(0,t.jsx)(n.admonition,{title:"\u5b89\u88c5\u62d3\u5c55\u5305\u4f4d\u7f6e",type:"important",children:(0,t.jsxs)(n.p,{children:["\u5728 ",(0,t.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u4e2d\uff0c\u63a8\u8350\u5c06\u62d3\u5c55\u5305 ",(0,t.jsx)(n.code,{children:"Furion.Extras.DatabaseAccessor.SqlSugar"})," \u5b89\u88c5\u5230 ",(0,t.jsx)(n.code,{children:"Furion.Core"})," \u5c42\u4e2d\u3002"]})}),"\n",(0,t.jsx)(n.h2,{id:"1013-\u57fa\u672c\u4f7f\u7528",children:"10.1.3 \u57fa\u672c\u4f7f\u7528"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u4f7f\u7528\u4e4b\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u51fd\u6570\u6ce8\u5165 ",(0,t.jsx)(n.code,{children:"ISqlSugarRepository"})," \u63a5\u53e3\uff0c\u5982\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,6}",children:"private readonly ISqlSugarRepository repository; // \u4ed3\u50a8\u5bf9\u8c61\uff1a\u5c01\u88c5\u7b80\u5355\u7684CRUD\r\nprivate readonly SqlSugarClient db; // \u6838\u5fc3\u5bf9\u8c61\uff1a\u62e5\u6709\u5b8c\u6574\u7684SqlSugar\u5168\u90e8\u529f\u80fd\r\npublic PersonService(ISqlSugarRepository sqlSugarRepository)\r\n{\r\n repository = sqlSugarRepository;\r\n db = repository.Context; // \u63a8\u8350\u64cd\u4f5c\r\n}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"1014-\u6570\u636e\u5e93\u64cd\u4f5c\u793a\u4f8b",children:"10.1.4 \u6570\u636e\u5e93\u64cd\u4f5c\u793a\u4f8b"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// ================== SqlSugarClient ================\r\n\r\n//\u67e5\u8be2\u529f\u80fd\r\nvar data1 =db.Queryable().First(it=>it.Id==1); //db.GetById(1);\r\n\r\nvar data2 = db.Queryable().ToList();// db.GetList();\r\n\r\n// ================== \u7b80\u5355\u4ed3\u50a8 ================\r\n\r\n//\u63d2\u5165\r\ndb.Insert(insertObj);\r\nvar id = db.InsertReturnIdentity(insertObj);\r\ndb.AsInsertable(insertObj).ExecuteCommand();\r\n\r\n//\u5220\u9664\r\ndb.Delete(insertObj);\r\ndb.Delete(it => it.Id == 1);\r\n\r\n//\u66f4\u65b0\r\ndb.Update(insertObj);\r\ndb.Update(it => new Order() { Name = "a", }, it => it.Id == 1);\r\n\r\n//\u5f02\u6b65\u65b9\u6cd5\u7528\u6cd5\r\ndb.Insert(insertObj);//\u540c\u6b65\r\ndb.InsertAsync(insertObj);//\u5f02\u6b65\r\n\r\n//\u5207\u6362\u4ed3\u50a8\r\nvar orderRespository=db.GetSimpleClient();\r\norderRespository.Insert(Order);\n'})}),"\n",(0,t.jsx)(n.h2,{id:"1015-sqlsugarclient-\u64cd\u4f5c\u793a\u4f8b",children:"10.1.5 SqlSugarClient \u64cd\u4f5c\u793a\u4f8b"}),"\n",(0,t.jsx)(n.h3,{id:"10151-\u57fa\u7840\u67e5\u8be2",children:"10.1.5.1 \u57fa\u7840\u67e5\u8be2"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'//\u67e5\u8be2\u6240\u6709\r\nvar getAll = db.Queryable().ToList();\r\n//\u67e5\u8be2\u524d10\r\nvar top10= db.Queryable().Take(10).ToList();\r\n//\u67e5\u8be2\u5355\u6761\r\nvar getFirst = db.Queryable().First(it=>it.Id==1);\r\n//with nolock\r\nvar getAllNoLock = db.Queryable().With(SqlWith.NoLock).ToList();\r\n//\u6839\u636e\u4e3b\u952e\u67e5\u8be2\r\nvar getByPrimaryKey = db.Queryable().InSingle(2);\r\n//\u67e5\u8be2\u603b\u548c\r\nvar sum = db.Queryable().Sum(it=>it.Id);\r\n//\u662f\u5426\u5b58\u5728\r\nvar isAny = db.Queryable().Where(it=>it.Id==-1).Any();\r\n//\u6a21\u7cca\u67e5\r\nvar list2 = db.Queryable().Where(it =>it.Name.Contains("jack")).ToList();\n'})}),"\n",(0,t.jsx)(n.h3,{id:"10152-\u8054\u8868\u67e5\u8be2",children:"10.1.5.2 \u8054\u8868\u67e5\u8be2"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"var list = db.Queryable((st, sc) => new JoinQueryInfos(\r\n JoinType.Left,st.SchoolId==sc.Id))\r\n .Select((st,sc)=>new{Id=st.Id,Name=st.Name,SchoolName=sc.Name}).ToList();\r\n\r\n\u751f\u6210\u7684Sql\u5982\u4e0b:\r\nSELECT [st].[ID] AS [id] ,\r\n [st].[Name] AS [name] ,\r\n [sc].[Name] AS [schoolName] FROM [STudent] st\r\n Left JOIN School sc ON ( [st].[SchoolId] =[sc].[Id])\n"})}),"\n",(0,t.jsx)(n.h3,{id:"10153-\u5206\u9875\u67e5\u8be2",children:"10.1.5.3 \u5206\u9875\u67e5\u8be2"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:" int pageIndex = 1;\r\n int pageSize = 20;\r\n int totalCount=0;\r\n var page = db.Queryable().ToPageList(pageIndex, pageSize, ref totalCount);\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u66f4\u591a\u67e5\u8be2\u7528\u6cd5 \uff1a ",(0,t.jsx)(n.a,{href:"http://www.donet5.com/Home/Doc?typeId=1185",children:"http://www.donet5.com/Home/Doc?typeId=1185"})]}),"\n",(0,t.jsx)(n.h3,{id:"10154-\u63d2\u5165",children:"10.1.5.4 \u63d2\u5165"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'//\u53ef\u4ee5\u662f \u7c7b \u6216\u8005 List<\u7c7b>\r\ndb.Insertable(insertObj).ExecuteCommand();\r\n\r\n//\u63d2\u5165\u8fd4\u56de\u81ea\u589e\u5217\r\ndb.Insertable(insertObj).ExecuteReturnIdentity();\r\n\r\n//\u53ef\u4ee5\u662f Dictionary \u6216\u8005 List\r\nvar dc= new Dictionary();\r\n dt.Add("name", "1");\r\n dt.Add("CreateTime", null);\r\ndb.Insertable(dc).AS("student").ExecuteCommand();\r\n\r\n//DataTable\u63d2\u5165\r\nDictionary dc= db.Utilities.DataTableToDictionary(dataTable);//\u8f6c\u6210\u5b57\u5178\u5c31\u53ef\u4ee5\u6309\u4e0a\u9762\u7684\u5b57\u5178\u66f4\u65b0\u4e86\r\ndb.Insertable(dc).AS("student").ExecuteReturnIdentity();\r\n\r\n//\u5b9e\u4f53\u53ef\u4ee5\u914d\u7f6e\u4e3b\u952e\u548c\u81ea\u589e\u5217\r\npublic class Student\r\n{\r\n [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]\r\n public int Id { get; set; }\r\n public int? SchoolId { get; set; }\r\n public string Name { get; set; }\r\n}\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u66f4\u591a\u63d2\u5165\u7528\u6cd5\uff1a ",(0,t.jsx)(n.a,{href:"http://www.donet5.com/Home/Doc?typeId=1193",children:"http://www.donet5.com/Home/Doc?typeId=1193"})]}),"\n",(0,t.jsx)(n.h3,{id:"10155-\u66f4\u65b0",children:"10.1.5.5 \u66f4\u65b0"}),"\n",(0,t.jsx)(n.p,{children:"\u5b9e\u4f53\u914d\u7f6e\u53c2\u8003\u63d2\u5165\uff0c\u53ea\u9700\u8981\u914d\u7f6e\u4e3b\u952e\u5373\u53ef"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'//\u6839\u636e\u4e3b\u952e\u66f4\u65b0\u5355\u6761 \u53c2\u6570 Class\r\nvar result= db.Updateable(updateObj).ExecuteCommand();\r\n//\u4e0d\u66f4\u65b0 Name \u548cTestId\r\nvar result=db.Updateable(updateObj).IgnoreColumns(it => new { it.CreateTime,it.TestId }).ExecuteCommand()\r\n//\u53ea\u66f4\u65b0 Name \u548c CreateTime\r\nvar result=db.Updateable(updateObj).UpdateColumns(it => new { it.Name,it.CreateTime }).ExecuteCommand();\r\n//\u6839\u636e\u8868\u8fbe\u5f0f\u66f4\u65b0\r\nvar result71 = db.Updateable()\r\n .SetColumns(it => it.Name == "a")\r\n .SetColumnsIF(p!=null ,it => it.CreateTime == p.Value)//\u5f53p\u4e0d\u7b49\u4e8enull\u66f4\u65b0createtime\u5217\r\n .Where(it => it.Id == 11).ExecuteCommand();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u66f4\u591a\u66f4\u65b0\u7528\u6cd5\uff1a ",(0,t.jsx)(n.a,{href:"http://www.donet5.com/Home/Doc?typeId=1191",children:"http://www.donet5.com/Home/Doc?typeId=1191"})]}),"\n",(0,t.jsx)(n.h3,{id:"10156-\u5220\u9664",children:"10.1.5.6 \u5220\u9664"}),"\n",(0,t.jsx)(n.p,{children:"\u5b9e\u4f53\u914d\u7f6e\u53c2\u8003\u63d2\u5165\uff0c\u53ea\u9700\u8981\u914d\u7f6e\u4e3b\u952e\u5373\u53ef"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"//\u6839\u636e\u5b9e\u4f53\u5220\u9664\r\ndb.Deleteable().Where(new Student() { Id = 1 }).ExecuteCommand();\r\n//\u6839\u636e\u4e3b\u952e\u5220\u9664\r\ndb.Deleteable().In(1).ExecuteCommand();\r\n//\u6839\u636e\u8868\u8fbe\u5f0f\u5220\u9664\r\ndb.Deleteable().Where(it => it.Id == 1).ExecuteCommand();\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u66f4\u591a\u5220\u9664\u7528\u6cd5: ",(0,t.jsx)(n.a,{href:"http://www.donet5.com/Home/Doc?typeId=1195",children:"http://www.donet5.com/Home/Doc?typeId=1195"})]}),"\n",(0,t.jsx)(n.h2,{id:"1016-sql-\u67e5\u8be2",children:"10.1.6 Sql \u67e5\u8be2"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'//sql\u5206\u9875\r\nvar list = db.SqlQueryable("select * from student").ToPageList(1, 2,ref total);\r\n\r\n//\u539f\u751fSql\u7528\u6cd5\r\nvar dt=db.Ado.GetDataTable("select * from table where id=@id and name=@name",new List(){\r\n new SugarParameter("@id",1),\r\n new SugarParameter("@name",2)\r\n});\r\n//\u53c2\u65702\r\nvar dt=db.Ado.GetDataTable("select * from table where id=@id and name=@name",new{id=1,name=2});\r\n\r\n//\u5b58\u50a8\u8fc7\u7a0b\u7528\u6cd5\r\nvar nameP= new SugarParameter("@name", "\u5f20\u4e09");\r\nvar ageP= new SugarParameter("@age", null, true);//\u8bbe\u7f6e\u4e3aoutput\r\nvar dt = db.Ado.UseStoredProcedure().GetDataTable("sp_school",nameP,ageP);\r\n\n'})}),"\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,t.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"}),(0,t.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd4\u56de\u503c"})]})}),(0,t.jsxs)(n.tbody,{children:[(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"SqlQuery"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u6240\u6709\u8fd4\u56de\u5b9e\u4f53\u96c6\u5408"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"List"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"SqlQuery"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u53ef\u4ee5\u8fd4\u56de 2 \u4e2a\u7ed3\u679c\u96c6"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"Tuple"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"SqlQuerySingle"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u7b2c\u4e00\u6761\u8bb0\u5f55"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"T"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetDataTable"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u6240\u6709"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"DataTable"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetDataReader"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u8bfb\u53d6 DR \u9700\u8981\u624b\u52a8\u91ca\u653e DR"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"DataReader"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetDataSetAll"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u591a\u4e2a\u7ed3\u679c\u96c6"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"DataSet"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"ExecuteCommand"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u53d7\u5f71\u54cd\u884c\u6570\uff0c\u4e00\u822c\u7528\u4e8e\u589e\u5220\u6539"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"int"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetScalar"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"object"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetString"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"string"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetInt"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"int"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetLong"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"long"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetDouble"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"Double"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetDecimal"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"Decimal"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"GetDateTime"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u9996\u884c\u9996\u5217"}),(0,t.jsx)(n.td,{style:{textAlign:"center"},children:"DateTime"})]})]})]}),"\n",(0,t.jsxs)(n.p,{children:["\u60f3\u4e86\u89e3\u66f4\u591a ",(0,t.jsx)(n.code,{children:"SqlSugar"})," \u77e5\u8bc6\u53ef\u67e5\u9605 ",(0,t.jsx)(n.a,{href:"http://donet5.com/",children:"SqlSugar \u5b98\u7f51"}),"\u3002"]}),"\n",(0,t.jsxs)(n.h2,{id:"1017-\u6253\u5370-sql-\u5230-swagger",children:["10.1.7 \u6253\u5370 ",(0,t.jsx)(n.code,{children:"sql"})," \u5230 ",(0,t.jsx)(n.code,{children:"Swagger"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'services.AddSqlSugar(new ConnectionConfig\r\n{\r\n ConnectionString = "Server=.xxxxx",//\u8fde\u63a5\u7b26\u5b57\u4e32\r\n DbType = DbType.SqlServer,\r\n IsAutoCloseConnection = true,\r\n InitKeyType = InitKeyType.Attribute//\u4ece\u7279\u6027\u8bfb\u53d6\u4e3b\u952e\u81ea\u589e\u4fe1\u606f\r\n},\r\ndb =>\r\n{\r\n db.Aop.OnLogExecuting = (sql, pars) =>\r\n {\r\n //\u65b9\u6cd5\u4e00\r\n App.PrintToMiniProfiler("SqlSugar", "Info", sql + "\\r\\n" +string.Join(",", pars?.Select(it => it.ParameterName + ":" + it.Value)));\r\n\r\n //\u65b9\u6cd5\u4e8c:Furion\u5bf9\u4e0a\u8ff0\u7528\u6cd5\u8fdb\u884c\u4e8c\u6b21\u5c01\u88c5 \u5efa\u8bae\u65b9\u5f0f Sql\u53c2\u6570\u4f1a\u76f4\u63a5\u5199\u5165\u5230\u751f\u6210Sql\u4e2d\r\n App.PrintToMiniProfiler("SqlSugar","Info",SqlProfiler.ParameterFormat(sql,pars));\r\n };\r\n});\n'})}),"\n",(0,t.jsxs)(n.h2,{id:"1018-oracle\u6ce8\u610f\u4e8b\u9879",children:["10.1.8 ",(0,t.jsx)(n.code,{children:"Oracle"}),"\u6ce8\u610f\u4e8b\u9879"]}),"\n",(0,t.jsxs)(n.p,{children:["\u6ce8\u610f .NET5 \u7528\u6237\u9700\u8981\u5728 API \u6216\u8005\u9879\u76ee\u89e3\u51b3\u65b9\u6848 ",(0,t.jsx)(n.code,{children:".csproj"})," \u6587\u4ef6\u52a0\u4ee5\u4e0b\u4e00\u884c\u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {3}",children:"\r\n net5.0\r\n true\r\n\n"})}),"\n",(0,t.jsx)(n.h2,{id:"1019-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"10.1.9 \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)(o,{...e})}):o(e)}},1151:(e,n,r)=>{r.d(n,{Z:()=>d,a:()=>l});var t=r(7294);const s={},i=t.createContext(s);function l(e){const n=t.useContext(i);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),t.createElement(i.Provider,{value:n},e.children)}}}]);