Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity framework result discrepancy for a database views
    text
    copied!<p>I have one specific view created in my DB(joins about 5-6 tables with a left join).This view is added to my edmx (entity framework 1.0) . Recently I noticed that one of the column records obtained using the edmx (linq to entities and then ToList()) got duplicated multiple times though in the database view they were different</p> <pre><code>Column-N (Expected result/ result from DB view) --------- data1 data2 data3 data4 data5 Column-N(Actual result generated by entity framework) --------- data1 data1 data1 data1 data1 </code></pre> <p>I fired up my SQL profiler,got the query which was sent by my application to the SQL Server, ran it and it returned me the expected result.</p> <p>MSDN has a similar post <a href="http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/68818bcf-86d3-4b98-993c-cf1143fa0d66" rel="noreferrer">here</a> and <a href="http://social.msdn.microsoft.com/Forums/en/linqprojectgeneral/thread/e25695d0-be93-47e2-beec-1dbb017e4dfd" rel="noreferrer">here</a> but the moderator has not elaborated on how to solve this problem. My key happens to be a GUID</p> <blockquote> <p>The root cause you pointed out I think is correct, the problem is on the application side EF mapping, as EF has different object mapping rules with database. when the query results have been returned from database, the EF will do the mapping on application memory according to its own designed logic.</p> <p>It's important to take these logic into account when you desingn your view query in your database side. I think you should do some adjustment on your view query.</p> <p>I am not sure whether you have sorted the problem, if not please provide the database structure related to this issue and the view query you have written.</p> <p>Thanks Binze</p> </blockquote> <p>Has someone encountered a similar problem before ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload