Skip to content

Commit

Permalink
Update DataRecordExtensions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Aug 8, 2024
1 parent b265373 commit 5ff91ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FluentCommand/Extensions/DataRecordExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ public static object GetValue(this IDataRecord dataRecord, string name)
public static T GetValue<T>(this IDataRecord dataRecord, string name)
{
int ordinal = dataRecord.GetOrdinal(name);
if (dataRecord.IsDBNull(ordinal))
return default;

if (dataRecord is DbDataReader dataReader)
return dataReader.GetFieldValue<T>(ordinal);

Expand All @@ -467,6 +470,9 @@ public static T GetValue<T>(this IDataRecord dataRecord, string name)
/// </returns>
public static T GetValue<T>(this IDataRecord dataRecord, int index)
{
if (dataRecord.IsDBNull(index))
return default;

if (dataRecord is DbDataReader dataReader)
return dataReader.GetFieldValue<T>(index);

Expand Down

0 comments on commit 5ff91ba

Please sign in to comment.