Skip to content

Commit ad24fcc

Browse files
Add an example to print properties values
1 parent 6470390 commit ad24fcc

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
"program": "${workspaceFolder}/bin/Debug/net6.0/print-database-property-name-and-values.dll",
13+
"args": [],
14+
"cwd": "${workspaceFolder}",
15+
"console": "internalConsole",
16+
"stopAtEntry": false
17+
},
18+
{
19+
"name": ".NET Core Attach",
20+
"type": "coreclr",
21+
"request": "attach"
22+
}
23+
]
24+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/print-database-property-name-and-values.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/print-database-property-name-and-values.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/print-database-property-name-and-values.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Notion.Client;
2+
3+
var client = new NotionClient(new ClientOptions
4+
{
5+
AuthToken = "<Token>"
6+
});
7+
8+
var databasesQueryParameters = new DatabasesQueryParameters();
9+
var databaseId = "";
10+
var queryResult = await client.Databases.QueryAsync(databaseId, databasesQueryParameters);
11+
12+
foreach (var result in queryResult.Results)
13+
{
14+
Console.WriteLine("Page Id: " + result.Id);
15+
foreach (var property in result.Properties)
16+
{
17+
Console.WriteLine(property.Key + " " + GetValue(property.Value));
18+
}
19+
}
20+
21+
object GetValue(PropertyValue p)
22+
{
23+
switch (p)
24+
{
25+
case RichTextPropertyValue richTextPropertyValue:
26+
return richTextPropertyValue.RichText.FirstOrDefault()?.PlainText;
27+
default:
28+
return null;
29+
}
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<RootNamespace>print_database_property_name_and_values</RootNamespace>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Notion.Net" Version="1.2.0"/>
10+
</ItemGroup>
11+
</Project>

0 commit comments

Comments
 (0)