View mapping, correct logged query, wrong result...

Thread is closed for posting
3 posts, 0 answers
  1. julien test
    julien test avatar
    15 posts
    Member since:
    Oct 2009

    Posted 25 May 2010 Link to this post

    Hi, I have a very strange problem.

    I created a complex view in SQL Server and mapped this View to a Open Access Class, say VContacts.

    The problem is that when I execute this request...

    var contacts = from c in scope.Extent<VContacts>() 
                            select c; 

    ...the result is not correct, I get the number of rows I should get, but they are the same instead of different ones.

    I traced the request to get the SQL query sent to SQL Server, I copied this query in a SQL Server query editor and I got the right result. (the rows are not the same).

    I tried to do the same query using an oql query, and the result is the same: Looking at the Open Access logs, the right query is sent to Sql Server, but in the List<Contacts> I get, I have the right number of items, but they are the same...

    Do you know where that problem could come from ? Is there an extra step between the result coming from the query sent to SQL Server (which seems to be right, according to Open Access Logs) and the populating of the actual result container ? 

    Thank you.

  2. Jan Blessenohl
    Jan Blessenohl avatar
    707 posts

    Posted 25 May 2010 Link to this post

    Hi julien test,
    You have specified the id column during reverse engieering. My feeling is that for all rows in your result this is is the same. This means we will instanciate the first row from your result and expect for all other rows that the object is already in memory. This results in a list that contains n times the same object.

    You should set the id for the view so that all rows are unique.

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. julien test
    julien test avatar
    15 posts
    Member since:
    Oct 2009

    Posted 25 May 2010 Link to this post

    Hi Jan,

    Your feeling was totally right. I added a second field as a primary key which solved the issue.

    Thank you very much.

Back to Top