This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Interesting issue.. I converted an EDMX -- Thanks again Jeremy for the nightly fix! -- and fixed a few mis-mapped fields using the Key Property Reference. The model now builds, but any basic query throws the exception; Unable to cast object of type ' . ' to type ' . '. I dropped the full stacktrace below. Not really clear on whether I'm doing something wrong or my model has a problem.. Has anyone seen this before?
|
|
|
I believe you may have this sorted but if not check that you are not setting a value for Key Property Reference when the association is not targeting a composite key based entity. This error is consistent with a value being set where the entity is using a normal identity type.
|
|
|
Hi, I am having the exact same issue.
This, or any toList(), Any(), etc. applied to the LINQ query is throwing an exception with the message Unable to cast object of type ' . ' to type ' . '. I don't understand your reply regarding the value for the key property reference. Could you explain further to a complete Lightspeed beginner please? I want to query a table, get the first result after ordering by, and check whether that result is null in database (as the field is a Nullable datetime). But I am getting this kind of Invalid Cast exception with no details about what type is trying to cast so I am very stuck here.. PS: This is the entity:
|
|
|
I got a workaround as I suspect that the problem is with the Order By HI.DateCleared.HasValue Ascending part but the I'm not sure if the cast exception not specifying what is the casting being attempted is related to this. Anyway, I changed my approach and now I have the following working and not crashing when converting to List or applying a count.
|
|