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

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

2 Answers 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
julien test
Top achievements
Rank 1
julien test asked on 25 May 2010, 10:55 AM
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 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 25 May 2010, 11:41 AM
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.
0
julien test
Top achievements
Rank 1
answered on 25 May 2010, 02:30 PM
Hi Jan,

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

Thank you very much.

Tags
General Discussions
Asked by
julien test
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
julien test
Top achievements
Rank 1
Share this question
or