Strange LINQ To Entities Exception

I am using a LINQ statement that selects from various tables information I need to fill some Post / Post Comment style records. I'm getting a funny exception saying that the object must implement IConvertible when I try to iterate the record set. The funny part about it is that it seems to only occur when the anonymous type I'm using to hold the data contains more than 2 generic collections.

//select friend timeline posts posts
var pquery = from friend in fquery
    join post in db.game_timeline on friend.id equals post.user_id
    //join user in db.users on post.friend_id equals user.id into userGroup
    //join game in db.games on post.game_id equals game.game_id into gameGroup
    select new
    {
        Friend = friend,
        Post = post,

        Game = from game in db.games
          where game.game_id == post.game_id
          select game,

        Recipient = from user in db.users
          where user.id == post.user_id
          select user,

        Comments = from comment in db.timeline_comments
          where comment.post_id == post.id
          join users in db.users on comment.user_id equals users.id
          select new { User = users, Comment = comment }
    };

(Note: I am using MYSQL Connector/Net so things like Take and FirstOrDefault and things like that are not supported within the LINQ statements themselves, I have opted to use those methods during iteration as it does not raise an exception there)

The problem is, when all 3 fields (Game, Recipient, and Comments) are present. I get the exception "Object must implement IConvertible". BUT if I remove ANY one of the 3 field assignments (doesn't matter which one), it works just fine. Anybody know what's going on here?

Thanks in advance!

Ryan.

32
задан SilverX 5 May 2011 в 20:29
поделиться