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
3333Connecting to your database is simple. For example, in C#:
3434
3535``` 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 ));
4543```
4644
4745For more information, see [ how to install] ( ./overview/installing/ ) and a [ basic example] ( ./tutorials/basic-api/ ) of using the API.
4846[ Many ORMs] ( /overview/use-with-orms/ ) are supported.
4947
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+
5063## Performance
5164
5265MySqlConnector outperforms Connector/NET (MySql.Data) on benchmarks:
You can’t perform that action at this time.
0 commit comments