在这里,我遇到了一些奇怪的情况。
我在 SQL Server 中创建了一个视图
Create View [Adm].[VwSurveyReport]
as
SELECT q.QuestionID,q.Question,p.dtStart,p.dtEnd,u.OrgCode,u.UserID,u.RoleID,
(case tc.blanswer
when 1 then 1
when 0 then 0
end) as AnsYes,
(case tc.blanswer
when 1 then 0
when 0 then 1
end) as AnsNo
from dbo.SurveyQuestions as q
left outer join dbo.surveyTransChild as tc on tc.questionID=q.questionID
left outer join dbo.surveyTransParent as tp on tp.SurveyTransID=tc.SurveyTransID
left outer join dbo.SurveyParent as p on p.surveyID=tp.surveyID
left outer join adm.masFEUser as u on tp.Userid=u.Userid
where p.dtStart IS Not NULL
GO
而我背后的代码是
List<ThePayWcfRef.VwSurveyReport> data = new List<ThePayWcfRef.VwSurveyReport>();
data = (from v in entities.VwSurveyReports
where 1 == 1
select v).ToList();
当我在 SQL Server 中运行选择查询时,它会显示我想要的确切输出
UserID RoleID AnsYes AnsNo
m6018upl 2 1 0
m6018upl 2 1 0
m6018app1 4 1 0
m6018app1 4 0 1
但是在我后面的代码中,我将错误的数据放入“数据”列表
UserID RoleID AnsYes AnsNo
m6018app1 4 1 0
m6018app1 4 0 1
m6018app1 4 1 0
m6018app1 4 0 1
AnsYes、AnsNo 和 UserID 错误
请帮我。
提前致谢。