Page 1 of 1

InvalidCastException since update

Posted: Tue 30 Oct 2012 08:17
by lc4pro
Hi,

since we started using 4.1.101 we have a lot InvalidCastException's.
Older versions never got a problem when we compared a Long with an ULong id, but now it throws an exception. The MySQL database has the field defined as int(10) UN PK AI.

Any idea what could be the problem?

Best regards,
Alex

Re: InvalidCastException since update

Posted: Tue 30 Oct 2012 12:07
by MariiaI
If we understood you correctly, you have the int(10) unsigned, PK, autoincrement column in the database and in the model it is mapped to ULong (Int64).
Could you please specify the following:
- the query with which you are getting the data;
- the stack trace of the exception.

Re: InvalidCastException since update

Posted: Wed 21 Nov 2012 12:21
by lc4pro
For general it seems the type-check in linq connect is much more precise.
Before the new version it was possible to use a String as an id for a where query if the id type in database was an integer

Code: Select all

db.Table.Where(function(x) x.id = idAsString)
This was really usefull, allowes a sloppier programming style but left you the decision how you like to program :)

The stronger type checking will become an annoyance if you have old code and suddently there are errors everywhere becauese of a stronger type checking in queries :(

So this is not a problem limited to one type conversion but a general problem!

Thanks for help!

Re: InvalidCastException since update

Posted: Mon 26 Nov 2012 15:12
by MariiaI
We have fixed some issues related to the casting of the numeric types (e.g., issues with the "Specified cast is not valid" exception). The fix will be available in the next build of LinqConnect, which we plan to release this week.
As for the implicitly converting strings to integer type in the queries as you posted above, thank you for the comment on this, we will investigate the possibility to implementing this functionality, but we can't tell any timeframe at the moment.

Re: InvalidCastException since update

Posted: Fri 30 Nov 2012 08:04
by MariiaI
New build of LinqConnect 4.1.137 is available for download now!
It can be downloaded from http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=31&t=25387