Skip to content

AdoNetSafeGet is a set of an extension method for IDataReader interface that provides a safe and clean way how to read data from data reader.

License

Notifications You must be signed in to change notification settings

ArturLavrov/AdoNetSafeGet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdoNetSafeGet

Build Status

AdoNetSafeGet is a set of an extension method for IDataReader interface that provides a safe and clean way how to read data from data reader.

Features:

  • Convenient strong type access to column value by name.
while(dataReader.Read){
    string city = dataReader.SafeGetString("Name");
}

instead of

while(dataReader.Read){
  int cityColumnIndex = dataReader.GetOrdinal("Name"); 
  string city = dataReader.GetString(cityColumnIndex);
}
  • efficient and clear way to handle DBNull values.
while(dataReader.Read){
    string city = dataReader.SafeGetString("Name");
}

instead of

while(dataReader.Read)
{
  if (row["value"] != DBNull.Value)
  {
    someObject.Member = row["value"];
  }
}
  • Abbility to specify default value if value is DBNull.
while(dataReader.Read){
    string city = dataReader.SafeGetString("Name", "default string value");
}

NB!

If you wouldn't specify a default value, the type default value will be returned.

About

AdoNetSafeGet is a set of an extension method for IDataReader interface that provides a safe and clean way how to read data from data reader.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages