db table created - tested through swagger ui
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
namespace Xylem.Common.Service.MeterProcessState.Extensions
|
||||
{
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public static class SqlDataReaderExtensions
|
||||
{
|
||||
public static async Task<int> GetIntAsync(this SqlDataReader sqlDataReader, int index)
|
||||
{
|
||||
if (await sqlDataReader.IsDBNullAsync(index))
|
||||
{
|
||||
return default(int);
|
||||
}
|
||||
|
||||
return sqlDataReader.GetInt32(index);
|
||||
}
|
||||
|
||||
public static async Task<long> GetLongAsync(this SqlDataReader sqlDataReader, int index)
|
||||
{
|
||||
if (await sqlDataReader.IsDBNullAsync(index))
|
||||
{
|
||||
return default(long);
|
||||
}
|
||||
|
||||
return sqlDataReader.GetInt64(index);
|
||||
}
|
||||
|
||||
public static async Task<DateTime> GetDateTimeAsync(this SqlDataReader sqlDataReader, int index)
|
||||
{
|
||||
if (await sqlDataReader.IsDBNullAsync(index))
|
||||
{
|
||||
return default(DateTime);
|
||||
}
|
||||
|
||||
return sqlDataReader.GetSqlDateTime(index).Value;
|
||||
}
|
||||
|
||||
public static async Task<float> GetFloatAsync(this SqlDataReader sqlDataReader, int index)
|
||||
{
|
||||
if (await sqlDataReader.IsDBNullAsync(index))
|
||||
{
|
||||
return default(float);
|
||||
}
|
||||
|
||||
return sqlDataReader.GetFloat(index);
|
||||
}
|
||||
|
||||
public static async Task<double> GetDoubleAsync(this SqlDataReader sqlDataReader, int index)
|
||||
{
|
||||
if (await sqlDataReader.IsDBNullAsync(index))
|
||||
{
|
||||
return default(double);
|
||||
}
|
||||
|
||||
return sqlDataReader.GetDouble(index);
|
||||
}
|
||||
|
||||
public static async Task<bool> GetBoolAsync(this SqlDataReader sqlDataReader, int index)
|
||||
{
|
||||
if (await sqlDataReader.IsDBNullAsync(index))
|
||||
{
|
||||
return default(bool);
|
||||
}
|
||||
|
||||
return sqlDataReader.GetBoolean(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user