System.OverflowException: Value was either too large or too small for an Int16

5 posts, 1 answers
  1. Igor
    Igor avatar
    145 posts
    Member since:
    Jan 2011

    Posted 27 Feb 2014 Link to this post

    Hi,

    i have faced with the following issue:
    in my domain class i have property with type UInt16 like that:

           public virtual ushort Property1
            {
                get
                {
                    return this._property1;
                }
                set
                {
                    this._property1 = value;
                }
            }

    however when running the following code, i am getting exception after saving the instance of value and accessing its UInt16 property like that:

    EntitiesModel1 model = new EntitiesModel1("Server=127.0.0.1;Database=telerikorm;Uid=telerikorm;Pwd=telerikorm;");
     
    Domain_class1 domain_class = new Domain_class1() { Property1 = 53464 };
     
    model.Add(domain_class);
    model.SaveChanges();
     
    Console.WriteLine(
        //DataStoreException was unhandled:
        //Error executing query: System.OverflowException: Value was either too large or too small for an Int16.
             domain_class.Property1.ToString()
                    );
     
     Console.ReadKey();

    The sample project is posted here: http://yadi.sk/d/nOan4wtfJfmMd

    Please help me to figure out why is it happening?
    Thanks!

  2. Answer
    Ady
    Admin
    Ady avatar
    589 posts

    Posted 03 Mar 2014 Link to this post

    Hi Igor,

     Thank you for the sample project. I was able to reproduce this exception. We do have unit tests for all .NET types but this workflow has been missed. We will add the appropriate tests. 
    As a workaround I have added a custom converter that is used for this field. This converter is specified for this field via the fluent code using the 'WithConverter(convererName)' extension method. I am attaching the same project with the modified code. 

    Your Telerik points have been updated.

    Regards,
    Ady
    Telerik
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
  3. DevCraft banner
  4. Igor
    Igor avatar
    145 posts
    Member since:
    Jan 2011

    Posted 03 Mar 2014 in reply to Ady Link to this post

    hi Ady,

    i see, thank you!
    i will try this converter shortly and let you know my results
  5. Igor
    Igor avatar
    145 posts
    Member since:
    Jan 2011

    Posted 07 Jul 2015 Link to this post

    hey guys, sorry for being late, I've tried the converter and it works just perfectly for me, however I got another issue with mapping in the ORM Designer. It tries to locate the converter type "SmallIntUnsigned_with_Uint16.UShortConverter" from Telerik.OpenAccess.Runtime assembly, which is not correct, since I have the custom assembly with this converter.

    see the video with the issue: https://www.dropbox.com/s/e0pff0t7bocyywd/disigner%20mapping%20error.avi?dl=0

    my ORM version is: 2013.2.73.5951 

    please advice, thanks!

  6. Ady
    Admin
    Ady avatar
    589 posts

    Posted 09 Jul 2015 Link to this post

    Hello Igor,

     You need to specify the assembly qualified name of the type that implements the converter.
    Can you make this change and test again?

    Regards,
    Ady
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top
DevCraft banner