From 56e901f0d10d51a4a0024e44a05e54b3126eac41 Mon Sep 17 00:00:00 2001 From: bicijinlian Date: Tue, 28 Mar 2023 00:35:58 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 多语言笔记.1.3.多语言.ipynb | 118 ++++++++++++++ 多语言笔记.100.1.测试.ipynb | 182 ++++++++++++++++++++++ 多语言笔记.2.1.连接数据库.ipynb | 105 ++++++++++++- 多语言笔记.6.1.共享变量.ipynb | 70 +++++++++ 4 files changed, 469 insertions(+), 6 deletions(-) create mode 100644 多语言笔记.1.3.多语言.ipynb create mode 100644 多语言笔记.100.1.测试.ipynb create mode 100644 多语言笔记.6.1.共享变量.ipynb diff --git a/多语言笔记.1.3.多语言.ipynb b/多语言笔记.1.3.多语言.ipynb new file mode 100644 index 0000000..2656e28 --- /dev/null +++ b/多语言笔记.1.3.多语言.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 同一笔记中使用多语言" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用C#" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 F#" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用Powershell" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 html" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 JavaScript" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 SQL" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 KQL" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 mermaind" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 使用 Raw Value Storage" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 使用 Rarzor" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "value" + }, + "polyglot_notebook": { + "kernelName": "value" + }, + "vscode": { + "languageId": "polyglot-notebook" + } + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "language_info": { + "name": "python" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/多语言笔记.100.1.测试.ipynb b/多语言笔记.100.1.测试.ipynb new file mode 100644 index 0000000..5f7a0fd --- /dev/null +++ b/多语言笔记.100.1.测试.ipynb @@ -0,0 +1,182 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 测试使用" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 全局引用" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "// 默认包源\n", + "#i \"https://api.nuget.org/v3/index.json\"\n", + "\n", + "//添加 Nuget 包\n", + "#r \"nuget: microsoft.dotNet.interactive.aspnetcore,*-*\"\n", + "#r \"nuget: Microsoft.DotNet.Interactive.ExtensionLab,*-*\"\n", + "//全局引用\n", + "\n", + "//全局变量" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 测试" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var names=new string[]{\"小张\",\"王明\",\"李立三\"};" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "#!share --help" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "javascript" + }, + "polyglot_notebook": { + "kernelName": "javascript" + } + }, + "outputs": [], + "source": [ + "let value = \"hello from js\"\n", + "\n", + "console.log(value)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "javascript" + }, + "polyglot_notebook": { + "kernelName": "javascript" + } + }, + "outputs": [], + "source": [ + "#!share names --from csharp --mime-type text/plain --as cc\n", + "\n", + "console.log(cc)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "javascript" + }, + "polyglot_notebook": { + "kernelName": "javascript" + } + }, + "outputs": [], + "source": [ + "var d =interactive.csharp\n", + "console.log(d)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "javascript" + }, + "polyglot_notebook": { + "kernelName": "javascript" + } + }, + "outputs": [], + "source": [ + "let va = await interactive.csharp.getVariable('names');\n", + "interactive.csharp" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "orig_nbformat": 4, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "name": "csharp" + }, + { + "aliases": [], + "name": "razor" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/多语言笔记.2.1.连接数据库.ipynb b/多语言笔记.2.1.连接数据库.ipynb index f72e42a..96f5a99 100644 --- a/多语言笔记.2.1.连接数据库.ipynb +++ b/多语言笔记.2.1.连接数据库.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -36,7 +36,37 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
  • Microsoft.Dotnet.Interactive.SqlServer, 1.0.0-beta.23165.2
" + ] + }, + "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,*-*\"" ] @@ -116,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -125,7 +155,17 @@ "kernelName": "csharp" } }, - "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=Study;Encrypt=True;TrustServerCertificate=True;\" --kernel-name Demo\n", "//重复执行会抛出错误,目前没有找到解决方法" @@ -214,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -223,7 +263,42 @@ "kernelName": "csharp" } }, - "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
  • Humanizer, 2.14.1
  • humanizer.core, 2.14.1
  • Microsoft.EntityFrameworkCore.Design, 7.0.0
  • microsoft.entityframeworkcore.sqlserver, 7.0.0
  • microsoft.identity.client, 4.48.1
" + ] + }, + "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=Study;Encrypt=True;TrustServerCertificate=True;\" --create-dbcontext --kernel-name DemoEF " ] @@ -302,6 +377,24 @@ "var c = context.Database.ExecuteSql(fs);\n", "display(c);" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "sql-DemoEF" + }, + "polyglot_notebook": { + "kernelName": "sql-DemoEF" + } + }, + "outputs": [], + "source": [ + "#!sql-DemoEF\n", + "\n", + "var data = from " + ] } ], "metadata": { diff --git a/多语言笔记.6.1.共享变量.ipynb b/多语言笔记.6.1.共享变量.ipynb new file mode 100644 index 0000000..245a83f --- /dev/null +++ b/多语言笔记.6.1.共享变量.ipynb @@ -0,0 +1,70 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 共享变量的使用" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 全局设置" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "// 默认包源\n", + "#i \"https://api.nuget.org/v3/index.json\"\n", + "\n", + "//Nuget 包引用\n", + "#r \"nuget: Microsoft.DotNet.Interactive.ExtensionLab,*-*\"\n", + "\n", + "//全局变量" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "orig_nbformat": 4, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "name": "csharp" + }, + { + "aliases": [], + "name": "razor" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}