This is a migrated thread and some comments may be shown as answers.

Issues With MySQL View

1 Answer 42 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sean
Top achievements
Rank 2
Sean asked on 27 Jul 2009, 03:20 AM
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

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 28 Jul 2009, 06:19 AM
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.
Tags
Databases and Data Types
Asked by
Sean
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Share this question
or