I use EF4 to read data from a view. This is a summary view with a group of etc. and read-only - it does not have a primary key. Therefore, to import into EF4, I used the often suggested trick - use ISNULL (column, -11) as the first column in the view. This helps EF4 derive the primary key and import the view.
However, when I select from a view in EF4, a very strange thing happens - I get the wrong data compared to when I directly select from a view in Studio Management. I could not believe it, so I tried it several times, and the error continued. Just to make sure I created the table in SQL Server, select everything from the view and view the table in EF4. But then the result will return the correct data!
The view is not very complex, except that it is a composite view (a group using joints), and it uses the SQL Common Table expression (i.e. the with clause).
When I select straight in database using select * from vw_responserate I get coltext SurveyId rowtext1 rowtext2 cnt Anwender 2 Angestellte/r Französische Schweiz 1 Anwender 2 Angestellte/r Italienische Schweiz 1 IT Spezialist 2 Angestellte/r Deutsche Schweiz 1 IT Spezialist 2 Mittleres Management / Senior Management Italienische Schweiz 1 When I select from EF4 I get coltext rowtext1 rowtext2 cnt Anwender Angestellte/r Französische Schweiz 1 Anwender Angestellte/r Französische Schweiz 1 IT Spezialist Angestellte/r Deutsche Schweiz 1 IT Spezialist Angestellte/r Deutsche Schweiz 1
Any help would be appreciated
thanks
josephj1989
source share