Skip to main content

C# extension methods for the DataRecord class.

public static class DataRecordExtensions
{
    public static bool HasColumn(this System.Data.IDataRecord self, string columnName)
    {
        for (int i = 0; i < self.FieldCount; i++)
        {
            if (self.GetName(i).Equals(columnName,
                StringComparison.InvariantCultureIgnoreCase))
            {
                return true;
            }
        }
        return false;
    }
}