Skip to content

Commit 54c2d1f

Browse files
committed
Driver/.NET: Add dedicated page
1 parent 9227a39 commit 54c2d1f

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

docs/connect/dotnet.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
(connect-dotnet)=
2+
3+
# .NET
4+
5+
:::{div} sd-text-muted
6+
Use Npgsql to connect to CrateDB from .NET applications.
7+
:::
8+
9+
:::{rubric} About
10+
:::
11+
12+
[Npgsql] is an open source ADO\.NET Data Provider for PostgreSQL, for programs
13+
written in C#, Visual Basic, and F#.
14+
15+
:::{rubric} Synopsis
16+
:::
17+
18+
```c#
19+
using Npgsql;
20+
21+
var connString = "Host=localhost;Username=crate;Password=crate;Database=testdrive";
22+
23+
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connString);
24+
25+
await using var dataSource = dataSourceBuilder.Build();
26+
await using var conn = await dataSource.OpenConnectionAsync();
27+
28+
await using var cmd = new NpgsqlCommand("SELECT mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3", conn);
29+
await using var reader = await cmd.ExecuteReaderAsync();
30+
while (await reader.ReadAsync())
31+
Console.WriteLine(reader.GetString(0), reader.GetString(1));
32+
```
33+
34+
## Examples
35+
36+
:::{card}
37+
:link: https://github.com/crate/cratedb-examples/tree/main/by-language/csharp-npgsql
38+
:link-type: url
39+
{material-outlined}`play_arrow;2em`
40+
Connect to CrateDB and CrateDB Cloud using .NET (C#)
41+
+++
42+
Demonstrates a basic example using Npgsql with CrateDB.
43+
:::
44+
45+
:::{card}
46+
:link: https://github.com/crate/cratedb-examples/tree/main/by-language/csharp-efcore
47+
:link-type: url
48+
{material-outlined}`play_arrow;2em`
49+
Connect to CrateDB and CrateDB Cloud using the Npgsql Entity Framework
50+
+++
51+
Demonstrates the Npgsql Entity Framework Core provider for PostgreSQL with CrateDB.
52+
:::
53+
54+
[![C# Npgsql](https://github.com/crate/cratedb-examples/actions/workflows/lang-csharp-npgsql.yml/badge.svg)](https://github.com/crate/cratedb-examples/actions/workflows/lang-csharp-npgsql.yml)
55+
[![C# EF Core](https://github.com/crate/cratedb-examples/actions/workflows/lang-csharp-efcore.yml/badge.svg)](https://github.com/crate/cratedb-examples/actions/workflows/lang-csharp-efcore.yml)
56+
57+
58+
[Npgsql]: https://www.npgsql.org/

docs/connect/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ CrateDB drivers and adapters for supported programming languages, frameworks, an
4949
:margin: 4 4 0 0
5050
:padding: 0
5151

52+
::::{grid-item-card} .NET
53+
:link: connect-dotnet
54+
:link-type: ref
55+
:link-alt: Connect to CrateDB using .NET
56+
:padding: 3
57+
:text-align: center
58+
:class-card: sd-pt-3
59+
:class-body: sd-fs-1
60+
:class-title: sd-fs-6
61+
```{image} https://images.seeklogo.com/logo-png/16/1/microsoft-net-logo-png_seeklogo-168315.png
62+
:width: 40px
63+
```
64+
::::
65+
5266
::::{grid-item-card} Java
5367
:link: connect-java
5468
:link-type: ref
@@ -182,6 +196,7 @@ application
182196
:maxdepth: 1
183197
:hidden:
184198
199+
dotnet
185200
java
186201
javascript
187202
php

0 commit comments

Comments
 (0)