diff --git a/Docs/Jupyter笔记.1.2.连接数据库.ipynb b/Docs/Jupyter笔记.1.2.连接数据库.ipynb index d2c05d9..03148bf 100644 --- a/Docs/Jupyter笔记.1.2.连接数据库.ipynb +++ b/Docs/Jupyter笔记.1.2.连接数据库.ipynb @@ -48,19 +48,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Loading extensions from `C:\\Users\\ruyu\\.nuget\\packages\\microsoft.dotnet.interactive.sqlserver\\1.0.0-beta.23165.2\\interactive-extensions\\dotnet\\Microsoft.DotNet.Interactive.SqlServer.dll`" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Query Microsoft SQL Server databases.\r\n", + "

This extension adds support for connecting to Microsoft SQL Server databases using the #!connect mssql magic command. For more information, run a cell using the #!sql magic command.

\r\n", + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#r \"nuget:Microsoft.Dotnet.Interactive.SqlServer,*-*\"" ] @@ -134,9 +161,6 @@ }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, "outputs": [], @@ -192,21 +216,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Kernel added: #!sql-Demo" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "#!connect mssql \"server=.\\SQL2008;uid=sa;pwd=gly-bicijinlian;database=Demo;Encrypt=True;TrustServerCertificate=True;\" --kernel-name Demo\n", + "#!connect mssql \"server=.\\SQL2008;uid=sa;pwd=gly-bicijinlian;database=Study;Encrypt=True;TrustServerCertificate=True;\" --kernel-name Demo\n", "//重复执行会抛出错误,目前没有找到解决方法" ] }, @@ -242,21 +273,73 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "dotnet_interactive": { "language": "sql-Demo" }, "polyglot_notebook": { "kernelName": "sql-Demo" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(2 行受到影响)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/csv": [ + "Id,Name,Age,Address,School,Grade,Room\r\n", + "1,王明明,5,五星小区21号301,太康一高,一年级,\r\n", + "2,张三丰,9,,太康一高,一年级,\r\n" + ], + "text/html": [ + "
IdNameAgeAddressSchoolGradeRoom
1
王明明
5
五星小区21号301太康一高一年级
2
张三丰
9
太康一高一年级
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "SELECT * from Test" + "SELECT * from Student" ] }, { @@ -291,22 +374,74 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(2 行受到影响)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/csv": [ + "Id,Name,Age,Address,School,Grade,Room\r\n", + "1,王明明,5,五星小区21号301,太康一高,一年级,\r\n", + "2,张三丰,9,,太康一高,一年级,\r\n" + ], + "text/html": [ + "
IdNameAgeAddressSchoolGradeRoom
1
王明明
5
五星小区21号301太康一高一年级
2
张三丰
9
太康一高一年级
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!sql-Demo\n", - "SELECT * from Test" + "SELECT * from Student" ] }, { @@ -341,21 +476,53 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "Scaffolding a `DbContext` and initializing an instance of it called `DemoEF` in the C# kernel." + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.\r\n" + ] + }, + { + "data": { + "text/plain": [ + "Kernel added: #!sql-DemoEF" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "#!connect mssql \"server=.\\SQL2008;uid=sa;pwd=gly-bicijinlian;database=Demo;Encrypt=True;TrustServerCertificate=True;\" --create-dbcontext --kernel-name DemoEF " + "#!connect mssql \"server=.\\SQL2008;uid=sa;pwd=gly-bicijinlian;database=Study;Encrypt=True;TrustServerCertificate=True;\" --create-dbcontext --kernel-name DemoEF " ] }, { @@ -408,22 +575,74 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(2 行受到影响)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/csv": [ + "Id,Name,Age,Address,School,Grade,Room\r\n", + "1,王明明,5,五星小区21号301,太康一高,一年级,\r\n", + "2,张三丰,9,,太康一高,一年级,\r\n" + ], + "text/html": [ + "
IdNameAgeAddressSchoolGradeRoom
1
王明明
5
五星小区21号301太康一高一年级
2
张三丰
9
太康一高一年级
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!sql-DemoEF\n", - "SELECT * from Test" + "SELECT * from Student" ] }, { @@ -443,26 +662,104 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" - }, - "vscode": { - "languageId": "polyglot-notebook" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
indexvalue
0
Submission#4+Student
Id
1
Name王明明
Age
5
Address五星小区21号301
School太康一高
Grade一年级
Room
1
Submission#4+Student
Id
2
Name张三丰
Age
9
Address
School太康一高
Grade一年级
Room
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
-1
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "//连接建立后,执行环境中就有了相关的类:DBContext等\n", "DemoEFContext context = new DemoEFContext();\n", - "var t = context.Tests.ToList();\n", + "var t = context.Students.ToList();\n", "display(t);\n", "\n", - "FormattableString fs = $\"select * from Test;\";\n", + "FormattableString fs = $\"select * from Student;\";\n", "var c = context.Database.ExecuteSql(fs);\n", "display(c);" ] @@ -474,39 +771,29 @@ "language": "C#", "name": ".net-csharp" }, + "language_info": { + "name": "polyglot-notebook" + }, "polyglot_notebook": { "kernelInfo": { "defaultKernelName": "csharp", "items": [ - { - "aliases": [ - "c#", - "C#" - ], - "languageName": "C#", - "name": "csharp" - }, { "aliases": [], - "languageName": "SQL", - "name": "sql" + "name": ".NET" }, { "aliases": [ - "frontend" + "C#", + "c#" ], - "languageName": null, - "name": "vscode" - }, - { - "aliases": [], - "languageName": null, - "name": ".NET" + "languageName": "C#", + "name": "csharp" }, { "aliases": [ - "f#", - "F#" + "F#", + "f#" ], "languageName": "F#", "name": "fsharp" @@ -533,9 +820,30 @@ "languageName": "PowerShell", "name": "pwsh" }, + { + "aliases": [], + "languageName": "SQL", + "name": "sql" + }, + { + "aliases": [], + "languageName": "T-SQL", + "name": "sql-Demo" + }, + { + "aliases": [], + "languageName": "T-SQL", + "name": "sql-DemoEF" + }, { "aliases": [], "name": "value" + }, + { + "aliases": [ + "frontend" + ], + "name": "vscode" } ] } diff --git a/MultiThreadingStudy.ConsoleApp/Program.cs b/MultiThreadingStudy.ConsoleApp/Program.cs index 20aa618..63b6bc2 100644 --- a/MultiThreadingStudy.ConsoleApp/Program.cs +++ b/MultiThreadingStudy.ConsoleApp/Program.cs @@ -2,7 +2,7 @@ namespace MultiThreadingStudy.ConsoleApp { internal class Program { - static async Task Main(string[] args) + static void Main(string[] args) { Console.WriteLine("多线程学习"); }