Type Converter not working

Posts   
 
    
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 06-Feb-2012 17:39:53   

Hi,

I am using LLBLGen Pro 3.1,SQL 2008, Oracle 11g and VS2010.

Table is defined as follows..

SQL

Test Int Not null

Oracle

Test NUMBER(10,) Not Null

since there is a conflict between .net type i have also wrote type converter to make them same. I have no issue with inserting data in both database, but when i am retrieving data on oracle database (type converter used in llblgen), i am getting "Specified Cast is not valid" Exception. Can you look at my type converter and see if you can find out anything.

Type Converter is attached here..

Attachments
Filename File size Added on Approval
IntInt64TypeConverter.cs 2,440 06-Feb-2012 17:40.05 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Feb-2012 05:28:03   

The first thing I see is that ConvertFrom and ConvertTo both should return true for Int64. So it should look like:

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
      {
        // any integer type is accepted. No fractional types like float/double.
        switch (sourceType.FullName)
        {
          case "System.Int64":
            return true;
          default:
            return false;
        }
      }

      public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
      {
        // any integer type is accepted. No fractional types like float/double.
        switch (destinationType.FullName)
        {
          case "System.Int64":
            return true;
          default:
            return false;
        }
      }

Then at ConvertFrom (where I guess the exception is originating), I don't see any obvious error, maybe some value at your DB is greater, maybe. You should debug the application and see what is the problematic value where the exception is occurring.

David Elizondo | LLBLGen Support Team