Skip to content

Commit ee4eff6

Browse files
committed
Remove guidance to use IsDBNullAsync.
Calling IsDBNull instead will always be more efficient.
1 parent 5ab8c68 commit ee4eff6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/content/tutorials/best-practices.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,9 @@ should be familiar with [Async/Await - Best Practices in Asynchronous Programmin
5454
<td>ExecuteScalar</td>
5555
</tr>
5656
<tr>
57-
<td rowspan="3" style="vertical-align:middle">
57+
<td rowspan="2" style="vertical-align:middle">
5858
<a href="https://docs.microsoft.com/en-us/dotnet/core/api/system.data.common.dbdatareader">DbDataReader</a>
5959
</td>
60-
<td>IsDBNullAsync</td>
61-
<td>IsDBNull</td>
62-
</tr>
63-
<tr>
6460
<td>NextResultAsync</td>
6561
<td>NextResult</td>
6662
</tr>
@@ -88,13 +84,17 @@ should be familiar with [Async/Await - Best Practices in Asynchronous Programmin
8884
<span class="text-danger">*</span>Async Transaction methods are not part of ADO.NET, they are provided by
8985
MySqlConnector to allow database code to remain fully asynchronous.
9086

91-
### Exception: DbDataReader.GetFieldValueAsync
87+
### Exceptions: DbDataReader.GetFieldValueAsync and IsDBNullAsync
9288

9389
Once `DbDataReader.ReadAsync` (or `DbDataReader.Read`) has returned `true`, the full contents of the current
94-
row are will be memory. Calling `GetFieldValue<T>` will return the value immediately (without blocking on I/O).
90+
row will be in memory. Calling `GetFieldValue<T>` will return the value immediately (without blocking on I/O).
9591
It will have higher performance than `GetFieldValueAsync<T>` because it doesn't have to allocate a `Task<T>`
9692
to store the result. There is no performance benefit to using the `DbDataReader.GetFieldValueAsync<T>` method.
9793

94+
Similarly, prefer to call `IsDBNull` instead of `IsDBNullAsync`; the information is already available and
95+
`IsDBNull` can return it immediately. (The async performance penalty isn't quite as bad because `IsDBNullAsync`
96+
uses cached `Task<bool>` objects for its `true` and `false` return values.)
97+
9898
### Example Console Application
9999

100100
In order to get the full benefit of asynchronous operation, every method in the call stack that eventually calls

0 commit comments

Comments
 (0)