InvalidCastException since update

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

InvalidCastException since update

Post by lc4pro » Tue 30 Oct 2012 08:17

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

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: InvalidCastException since update

Post by MariiaI » Tue 30 Oct 2012 12:07

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.

lc4pro
Posts: 51
Joined: Thu 12 Jul 2012 08:16

Re: InvalidCastException since update

Post by lc4pro » Wed 21 Nov 2012 12:21

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!

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: InvalidCastException since update

Post by MariiaI » Mon 26 Nov 2012 15:12

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.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: InvalidCastException since update

Post by MariiaI » Fri 30 Nov 2012 08:04

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

Post Reply