Need new FbDataReader methods
-----------------------------

                 Key: DNET-546
                 URL: http://tracker.firebirdsql.org/browse/DNET-546
             Project: .NET Data provider
          Issue Type: Improvement
          Components: ADO.NET Provider
    Affects Versions: 4.1.0.0
         Environment: Visual Studio 2012, .NET 4.0
            Reporter: Gabor Lakatos
            Assignee: Jiri Cincura
            Priority: Minor


I have new extension form FbDataReader class. I extend Get... (GetString, 
GetInt32, etc) methods for new parameters. Example: GetString("FIELDNAME", 
"DefaultValue").

The code:

using System;
using FirebirdSql.Data.FirebirdClient;

public static class FbDataReaderEx
{
    public static bool GetBoolean(this FbDataReader oR, string FieldName, bool 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetBoolean(oR.GetOrdinal(FieldName));
        }
    }

    public static byte GetByte(this FbDataReader oR, string FieldName, byte 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetByte(oR.GetOrdinal(FieldName));
        }
    }
    
    public static DateTime GetDateTime(this FbDataReader oR, string FieldName, 
DateTime Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetDateTime(oR.GetOrdinal(FieldName));
        }
    }
    
    public static decimal GetDecimal(this FbDataReader oR, string FieldName, 
decimal Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetDecimal(oR.GetOrdinal(FieldName));
        }
    }
    
    public static double GetDouble(this FbDataReader oR, string FieldName, 
double Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetDouble(oR.GetOrdinal(FieldName));
        }
    }
    
    public static Type GetFieldType(this FbDataReader oR, string FieldName)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return null;
        }
        else
        {
            return oR.GetFieldType(oR.GetOrdinal(FieldName));
        }
    }
    
    public static float GetFloat(this FbDataReader oR, string FieldName, float 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetFloat(oR.GetOrdinal(FieldName));
        }
    }
    
    public static Guid GetGuid(this FbDataReader oR, string FieldName, Guid 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetGuid(oR.GetOrdinal(FieldName));
        }
    }
    
    public static Int16 GetInt16(this FbDataReader oR, string FieldName, Int16 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetInt16(oR.GetOrdinal(FieldName));
        }
    }
    
    public static Int32 GetInt32(this FbDataReader oR, string FieldName, Int32 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetInt32(oR.GetOrdinal(FieldName));
        }
    }
    
    public static Int64 GetInt64(this FbDataReader oR, string FieldName, Int64 
Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetInt64(oR.GetOrdinal(FieldName));
        }
    }
    
    public static string GetString(this FbDataReader oR, string FieldName, 
string Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetString(oR.GetOrdinal(FieldName));
        }
    }
    
    public static object GetValue(this FbDataReader oR, string FieldName, 
object Default)
    {
        if (oR.IsDBNull(oR.GetOrdinal(FieldName)))
        {
            return Default;
        }
        else
        {
            return oR.GetValue(oR.GetOrdinal(FieldName));
        }
    }
    
    public static bool IsDBNull(this FbDataReader oR, string FieldName)
    {
        return oR.IsDBNull(oR.GetOrdinal(FieldName));
    }
}

I would be happy if the new procedures would appear in the new version.

Thanks,
    Gabor

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to