NpgsqlDataReaderSafetyGet 1.0.0
dotnet add package NpgsqlDataReaderSafetyGet --version 1.0.0
NuGet\Install-Package NpgsqlDataReaderSafetyGet -Version 1.0.0
<PackageReference Include="NpgsqlDataReaderSafetyGet" Version="1.0.0" />
paket add NpgsqlDataReaderSafetyGet --version 1.0.0
#r "nuget: NpgsqlDataReaderSafetyGet, 1.0.0"
// Install NpgsqlDataReaderSafetyGet as a Cake Addin #addin nuget:?package=NpgsqlDataReaderSafetyGet&version=1.0.0 // Install NpgsqlDataReaderSafetyGet as a Cake Tool #tool nuget:?package=NpgsqlDataReaderSafetyGet&version=1.0.0
NpgsqlDataReaderSafety
This is a simple tool to avoid exceptions with get
methods on DataReader
class.
With extension methods we can simple the get
data action on data reader, and receive a null value of each type when call a get
method of same type.
Usage Example And Explanations
When, in a DataReader object we call get method like this
while(dataReader.Read()){
people.Age = dataReader.GetInt32(0);
}
If database field in 0 position is null, we receive an exception. Following the documentation of Npgsql we can found a boolean method to check if the value is null called IsDBNull
, and our code will stay like this
while(dataReader.Read()){
if (!if(dataReader.IsDBNull(0)){
people.Age = dataReader.GetInt32(0);
}
}
The problem was solved, but we add some lines of code in our software and it got a little bit more unreadable for me. To handle with this I created this extension methods and I'd like to share. So our code will stay like this
while(dataReader.Read()){
people.Age = dataReader.GetSafetyInt32(0);
}
To do
- Add more type of extension methods
- Add
Try
blocks to handle knowled exceptions
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Npgsql (>= 4.0.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NpgsqlDataReaderSafetyGet:
Package | Downloads |
---|---|
RPA.AtualizaDrivers
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 3,757 | 4/15/2019 |