我正在使用下面的查询,它在Linqpad中给我一个正确的结果,但是当我在EF中使用相同的查询时,它给我错误的结果或浏览器上的多个结果。在查询中我从商店程序返回记录。
((from sp in spCV(12).AsEnumerable()
select new
{
HRUserID = sp.HRUserID,
FirstName = sp.FirstName,
DOB = sp.DOB,
Gender = sp.Gender,
Qualification = sp.Qualification,
Institute = sp.Institutes,
StartDate = sp.StartDate,
EndDate = sp.EndDate,
FieldofStudy = sp.FieldofStudy,
Course = sp.Course,
CFieldofStudy = sp.CFieldofStudy,
CInstitute = sp.Institute,
CStartDate = sp.CStartDate,
CEndDate = sp.CEndDate,
})
.GroupBy(x => new
{
x.HRUserID,
x.DOB,
x.FirstName,
x.Gender,
}).Distinct()
.Select(x => new
{
HRUserID = x.Key.HRUserID.Value,
FirstName = x.Key.FirstName,
DOB = x.Key.DOB ?? x.Key.DOB.Value,
Gender = x.Key.Gender,
AcademicInformations = x.Select(z => new
{
Qualification = z.Qualification,
Institute = z.Institute,
StartDate = z.StartDate,
EndDate = z.EndDate,
}).Distinct(),
ProfessionalTrainings = x.Select(pt => new
{
Course = pt.Course,
FieldofStudy = pt.CFieldofStudy,
Institute = pt.CInstitute,
StartDate = pt.CStartDate,
EndDate = pt.CEndDate,
}).Distinct(),
})).FirstOrDefault()