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.
2.6 KiB
2.6 KiB
使用 扩展库 Microsoft.DotNet.Interactive.ExtensionLab
添加 Nuget 包, 成功后有用法摘要提示
// 可以先添加包源
#i "nuget:https://api.nuget.org/v3/index.json"
//添加 Nuget 包
#r "nuget: Microsoft.DotNet.Interactive.ExtensionLab,*-*"
使用 #!linqify 创建强类型的 数据帧
#!linqify magic命令将 Microsoft.Data.Analysis.DataFrame 变量替换为生成的强类型数据帧,从而允许对包含的数据使用LINQ操作。
#!linqify frame --show-code
ExplainCode
这个扩展使用 Mermaid 内核从 csharp 代码生成序列图
使用 #!inspect 命令,检查代码编译详细信息!
#!inspect 命令,允许您查看C#单元格代码的反编译、IL和JIT Asm. 注意:深色模式下,展示区顶部的Tab[C# | IL JIT | ASM]不明显,但可以正常点击切换,或者换个VSCode主题。
#!inspect
foreach(var x in Enumerable.Range(1,10))
{
Console.WriteLine(x);
}
使用 #!record命令来保存您运行的代码的副本
一旦您使用 #!recore 启用转录本记录,每个代码提交(包括重新运行的单元格)都记录在指定的文件中。所使用的JSON格式与.NET Interactive stdio和http API识别的格式相同,可用于通过自动化回放交互式会话。
#!record --output recore.json
//会在笔记所在的目录生成 recore.json 文件
Console.WriteLine("#!record");
查询 SQLite 数据库
此扩展添加了对使用 #!connect sqlite 命令连接到SQLite数据库的支持!有关详细信息,请使用 #!sql 魔术命令。
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=SQLiteDemo.db"
/*
相对目录位置
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=Database\SQLiteDemo.db;"
缓存共享
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=Database\SQLiteDemo.db;Cache=Shared;"
使用带密码
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=SQLiteDemo.db;Cache=Shared;Password=MyEncryptionKey;"
只读模式
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=SQLiteDemo.db;Mode=ReadOnly"
读写创建模式
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=SQLiteDemo.db;Mode=ReadWriteCreate"
读写模式
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=SQLiteDemo.db;Mode=ReadWrite"
私有内存模式
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=:memory:"
共享内存模式
#!connect sqlite --kernel-name MySQLiteDemo "Data Source=Sharable;Mode=Memory;Cache=Shared"
*/
#!sql-MySQLiteDemo
select * from person;