File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -33,20 +33,33 @@ Install MySqlConnector from [NuGet](https://www.nuget.org/packages/MySqlConnecto
33
33
Connecting to your database is simple. For example, in C#:
34
34
35
35
``` csharp
36
- using (var connection = new MySqlConnection (" Server=myserver;User ID=mylogin;Password=mypass;Database=mydatabase" ))
37
- {
38
- connection .Open ();
39
-
40
- using (var command = new MySqlCommand (" SELECT field FROM table;" , connection ))
41
- using (var reader = command .ExecuteReader ())
42
- while (reader .Read ())
43
- Console .WriteLine (reader .GetString (0 ));
44
- }
36
+ using var connection = new MySqlConnection (" Server=myserver;User ID=mylogin;Password=mypass;Database=mydatabase" );
37
+ connection .Open ();
38
+
39
+ using var command = new MySqlCommand (" SELECT field FROM table;" , connection );
40
+ using var reader = command .ExecuteReader ();
41
+ while (reader .Read ())
42
+ Console .WriteLine (reader .GetString (0 ));
45
43
```
46
44
47
45
For more information, see [ how to install] ( ./overview/installing/ ) and a [ basic example] ( ./tutorials/basic-api/ ) of using the API.
48
46
[ Many ORMs] ( /overview/use-with-orms/ ) are supported.
49
47
48
+
49
+ ### Asynchronous I/O
50
+
51
+ MySqlConnector also fully supports asynchronous I/O. The C# example above can be rewritten as:
52
+
53
+ ``` csharp
54
+ await using var connection = new MySqlConnection (" Server=myserver;User ID=mylogin;Password=mypass;Database=mydatabase" );
55
+ await connection .OpenAsync ();
56
+
57
+ using var command = new MySqlCommand (" SELECT field FROM table;" , connection );
58
+ await using var reader = await command .ExecuteReaderAsync ();
59
+ while (await reader .ReadAsync ())
60
+ Console .WriteLine (reader .GetString (0 ));
61
+ ```
62
+
50
63
## Performance
51
64
52
65
MySqlConnector outperforms Connector/NET (MySql.Data) on benchmarks:
You can’t perform that action at this time.
0 commit comments