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
|
I've got the following table in my MySQL db, CREATE TABLE IF NOT EXISTS `PlayerTurns` (
I'm trying to grab some items from a neighbouring table "Games", like this : List<Game> x = uow.Playerturns.Select(pt => pt.Game).Distinct().ToList();
Which results in : Unable to materialize field [UserId] on type [ModularEnergy.Server.DAL.Playerturn]. Check your table has an Id column and that your mappings are correct. See inner exception for details. at Mindscape.LightSpeed.LightSpeedException.(Exception , String , Object[] )
Can you tell me what's the problem? I've checked the users table and it seems fine, here's it's definition : CREATE TABLE IF NOT EXISTS `Users` (
|
|
|
Anyone? I still haven't managed to figure this one out |
|
|
The first thing to do is check the InnerException of the LightSpeedException. This should give you a hint as to the nature of the error. A typical cause is a type mismatch, where the property is declared as one type in LightSpeed but it is coming back from the MySQL driver as another. (A particular example of this is when the LightSpeed property is non-nullable but the value that comes back from the database is DBNull.Value -- but that shouldn't be possible in your case.) We do have a known issue where if two fields are mapped to the same column, this can cause our data reader to get out of sync with our entity model. So if the inner exception tells you that the database is "can't cast Double to Int32," that probably means LightSpeed is trying to map TurnMoney into UserId. This might happen if you have a UserId field on the designer *as well as* an association whose column name is set to UserId. The association implicitly creates a FK field so you don't need to have the FK field explicitly. (Recent builds of the designer detect this case and raise an error.) Also, we have made some fixes around LINQ projections in recent weeks -- if you're on 3.0 RTM or an older nightly build then it might be worth upgrading to see if that solves the problem. If that doesn't help, can you post your PlayerTurn class and the generated SQL so we can investigate in more depth? Thanks! |
|