|
using System;
using System.Data;
using Robin.Sample.Framework;
namespace Robin.Sample.Data
{
public abstract class DataAccessComponent
{
protected string ConnectionString
{
get { return ConfigurationData.DBConnectionString; }
}
protected T GetDataValue<T>(IDataReader vobjDataReader, string vstrColumnName)
{
// NOTE: GetOrdinal() is used to automatically determine where the column
// is physically located in the database table. This allows the
// schema to be changed without affecting this piece of code.
// This of course sacrifices a little performance for maintainability.
int intOrdinal = vobjDataReader.GetOrdinal(vstrColumnName);
if (!vobjDataReader.IsDBNull(intOrdinal))
return (T)vobjDataReader.GetValue(intOrdinal);
else
return default(T);
}
protected T GetDataValue<T>(IDataReader vobjDataReader, int vintColumnIndex)
{
if (!vobjDataReader.IsDBNull(vintColumnIndex))
return (T)vobjDataReader.GetValue(vintColumnIndex);
else
return default(T);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.