Issues With MySQL View

2 posts, 0 answers
  1. Sean
    Sean  avatar
    54 posts
    Member since:
    Apr 2008

    Posted 26 Jul 2009 Link to this post

    I have a view that pulls data from a pair of tables. Table 1 is a list of messages for a user, table 2 is the user table itself.
    When I open the view in MySQL, I see my two test messages in the system. One indicates unread, the other read (as desired).

    However, when the list is queried through my application, it pulls one message twice and the other does not show. I have been racking my brain to find it, but am at a loss. Below is the relevant code.

                //Get all messages for this user in this game 
        //tUser is an object indicating the currently logged-in user 
                var tmessages = (from m in sc.Extent<Vusermessage>() 
                             where m.ReceiverId == tUser.UserId && m.GameId == GameID 
                             select m).ToList(); 
     
                //Split the result into saved and unsaved 
                var umessages = (from m in tmessages 
                                where !m.IsSaved  
                                select m 
                                 ).ToList(); 
     
                var smessages = (from s in tmessages 
                                 where s.IsSaved  
                                 select s 
                                 ).ToList(); 
     
                gridSavedMessages.DataSource = smessages; 
                gridSavedMessages.DataBind(); 
                gridMessages.DataSource = umessages; 
                gridMessages.DataBind(); 

    The code is straightforward, I think. And. as I said, when i open the view in MySQL< I see both messages. The result of tmessages, however, is to return one message twice.

    Ideas?

    Sean
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 28 Jul 2009 Link to this post

    Hello Sean,

    In order to display proper results Telerik OpenAccess ORM requires an identity field to be set for each class. In your case, if the view exposes the primary key column MessageID, you can set the MessageID field as identity. For more details, please read this blog post. Setting the primary key is described in Step 3.

    Best wishes,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
Back to Top