获得ef(dbfirst)和Sql Query之间的差异结果

时间:2021-03-25 13:26:37

Before Start I Have View 'PageViewModSession' its code is

在开始之前我有查看'PageViewModSession'的代码是

 SELECT        CONVERT(datetime, CONVERT(varchar(14), VisitStartDateTime) +    ':00:00') AS DateValue, MAX(dbo.PageLogGroupByDateTimeFull(VisitStartDateTime))  AS PageLogCount, 
                     (CASE MAX(dbo.SessionGroupByDateTimeFull(VisitStartDateTime)) WHEN 0 THEN 1 ELSE MAX(dbo.SessionGroupByDateTimeFull(VisitStartDateTime)) END) AS SessionLogCount, SiteInfoID
FROM            dbo.PageLog
GROUP BY CONVERT(varchar(14), VisitStartDateTime), SiteInfoID

and When select this views my result is 获得ef(dbfirst)和Sql Query之间的差异结果

当选择此视图时,我的结果是

and when select in ef with this syntaxt

当用这个合成文本在ef中选择时

 var obj = db.PageViewModSessions.AsQueryable();

result is
获得ef(dbfirst)和Sql Query之间的差异结果

结果是

repeat row one in every row on result

在结果的每一行重复第一行

i catch created Sql query query in profiler

我在分析器中捕获创建的Sql查询查询

SELECT 
[Extent1].[DateValue] AS [DateValue], 
[Extent1].[PageLogCount] AS [PageLogCount], 
[Extent1].[SessionLogCount] AS [SessionLogCount], 
[Extent1].[SiteInfoID] AS [SiteInfoID]
FROM (SELECT 
[PageViewModSession].[DateValue] AS [DateValue], 
[PageViewModSession].[PageLogCount] AS [PageLogCount], 
[PageViewModSession].[SessionLogCount] AS [SessionLogCount], 
[PageViewModSession].[SiteInfoID] AS [SiteInfoID]
FROM [dbo].[PageViewModSession] AS [PageViewModSession]) AS [Extent1]

and result is

结果是

2015-11-03 01:00:00.000        19        9        2
2015-11-03 02:00:00.000        19        4        2
2015-11-03 03:00:00.000        4        1        2
2015-11-03 11:00:00.000        7        5        2
2015-11-03 12:00:00.000        9        2        2
2015-11-04 01:00:00.000        1        1        2
2015-11-04 02:00:00.000        12        1        2
2015-11-04 03:00:00.000        5        1        2
2015-11-04 05:00:00.000        1        1        2
2015-11-04 06:00:00.000        4        1        2
2015-11-04 10:00:00.000        20        2        2
2015-11-04 11:00:00.000        19        4        2
2015-11-04 12:00:00.000        23        18        2
2015-11-05 02:00:00.000        1        1        2
2015-11-05 03:00:00.000        5        1        2
2015-11-05 04:00:00.000        25        2        2
2015-11-05 10:00:00.000        2        1        2
2015-11-05 11:00:00.000        3        1        2

why ?!!

为什么?!!

and what have to do fix this problem

以及需要做些什么来解决这个问题

1 个解决方案

#1


0  

I handle This by Setting Two Key for model DateValueand SiteInfoId

我通过设置模型DateValue和SiteInfoId的两个键来处理这个

#1


0  

I handle This by Setting Two Key for model DateValueand SiteInfoId

我通过设置模型DateValue和SiteInfoId的两个键来处理这个