Entity Framework: a request for a view in EF (C # code) returns duplicate results

I use EF to query the DB view. a query can return the correct number of records , but all records are the same. However, when I run the raw request in SSMS SSl, everything is fine.
Can someone give a hint about a possible root cause?

The view definition looks like:

 CREATE VIEW [dbo].[v_JobAEWeekly]
  AS
  SELECT        
  VCId, 
  JobRegistryId, 
  JobNamingId, 
  JobPrefix, 
  DATEADD(dd, DATEDIFF(week, CONVERT(DATETIME, '2013-01-01 00:00:00', 102), JobDate) * 7 - 2, CONVERT(DATETIME, '2013-01-01 00:00:00', 102)) AS JobDateWeekSeqStartDate,       
  COUNT(*) AS JobCounts,    
  FROM            dbo.HistoricalJobInfo
  WHERE        (JobStateId = 2) AND (TotalYieldTimeInMinutes = 0)
  GROUP BY VCId, JobRegistryId, JobNamingId, JobPrefix, DATEADD(dd, DATEDIFF(week, CONVERT(DATETIME, '2013-01-01 00:00:00', 102), JobDate) * 7 - 2, CONVERT(DATETIME, '2013-01-01 00:00:00', 102))

  GO

And the request is like:
  

//Problem:This query will return two records but the two records are the same. 
var jobAEWeeklyHistory = contextDjs.v_JobAEWeekly.Where(x => x.JobRegistryId == 11 && x.JobDateWeekSeqStartDate > date).ToList();
+3
source share
2 answers

Reverse engineering code at first is actually similar to Database First in the sense that it creates models, mappings, and a data context for you.

, , @Aducci. .

+2

.
EF , , . / , EF . , , EF , , . EF , .

+1

Source: https://habr.com/ru/post/1618961/


All Articles