This is a migrated thread and some comments may be shown as answers.

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

5 Answers 945 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Igor
Top achievements
Rank 2
Igor asked on 27 Feb 2014, 08:47 PM
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!

5 Answers, 1 is accepted

Sort by
0
Accepted
Ady
Telerik team
answered on 03 Mar 2014, 11:00 AM
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.
0
Igor
Top achievements
Rank 2
answered on 03 Mar 2014, 01:08 PM
hi Ady,

i see, thank you!
i will try this converter shortly and let you know my results
0
Igor
Top achievements
Rank 2
answered on 07 Jul 2015, 08:33 AM

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!

0
Ady
Telerik team
answered on 09 Jul 2015, 09:08 AM
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.
0
Mahendran
Top achievements
Rank 1
answered on 16 Jun 2017, 09:26 PM

Each type of integer has a different range of storage capacity

Type            Capacity

Int16 -- (-32,768 to +32,767)

Int32 -- (-2,147,483,648 to +2,147,483,647)

Int64 -- (-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807)

Tags
General Discussions
Asked by
Igor
Top achievements
Rank 2
Answers by
Ady
Telerik team
Igor
Top achievements
Rank 2
Mahendran
Top achievements
Rank 1
Share this question
or