Skip to content

Commit 4b56b03

Browse files
committed
Driver: Add page about .NET
1 parent 91d3c42 commit 4b56b03

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+
var dataSource = dataSourceBuilder.Build();
25+
26+
var conn = await dataSource.OpenConnectionAsync();
27+
28+
await using (var cmd = new NpgsqlCommand("SELECT * FROM sys.summits ORDER BY height DESC LIMIT 3", conn))
29+
await using (var reader = await cmd.ExecuteReaderAsync())
30+
{
31+
while (await reader.ReadAsync())
32+
Console.WriteLine(reader.GetString(0));
33+
}
34+
```
35+
36+
37+
## Examples
38+
39+
:::{card}
40+
:link: https://github.com/crate/cratedb-examples/tree/main/by-language/csharp-npgsql
41+
:link-type: url
42+
{material-outlined}`play_arrow;2em`
43+
Connect to CrateDB and CrateDB Cloud using .NET (C#)
44+
+++
45+
Demonstrates a basic example using Npgsql with CrateDB.
46+
:::
47+
48+
:::{card}
49+
:link: https://github.com/crate/cratedb-examples/tree/main/by-language/csharp-efcore
50+
:link-type: url
51+
{material-outlined}`play_arrow;2em`
52+
Connect to CrateDB and CrateDB Cloud using the Npgsql Entity Framework
53+
+++
54+
Demonstrates the Npgsql Entity Framework Core provider for PostgreSQL with CrateDB.
55+
:::
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)