Extension functions package for IDataReader implementations.
This library is part of Maestria Project.
Maestria is a project to provide maximum productivity and elegance to your code.
First, install NuGet. Then, install Maestria.Extensions.Data from the package manager console:
PM> Install-Package Maestria.Extensions.Dataor install from the dotnet cli command line:
> dotnet add package Maestria.Extensions.DataFirst, import "Maestria.Extensions.Data" reference:
using Maestria.Extensions.Data;Then in your application code, use fluent syntax to obtain field value:
// Configuring data connection
var connection = // your .net data provider db connection
var cmd = connection.CreateCommand();
cmd.CommandText = "select * from...";
var reader = cmd.ExecuteReader();
reader.Read();
// In this case throw exception when field value is null
var int16Value = reader.GetInt16("fieldName");
var int32Value = reader.GetInt32("fieldName");
var decimalValue = reader.GetDecimal("fieldName");
// With safe method when field value is null, it will return default value of the second argument or INullable<?> for data type
var decimalSafeValue = reader.GetDecimalSafe("fieldName", 0); // output is 0 when invalid field value
var decimalSafeValue2 = reader.GetDecimalSafe("fieldName"); // output is nyll when invalid field value
// But safe methods, throw exception when field name is invalid
var temp = reader.GetDecimalSafe("invalid field name"); // throw IndexOutOfRangeExceptionIf my contributions helped you, please help me buy a coffee :D


