Ich habe eine SQL-Abfrage, die mir rund 30 Datensatz geben wird, aber die gleiche Abfrage, sobald ich auf linq Abfrage änderte es gibt mir Tausende von Datensatz. Ich kann nicht die eigentliche Ursache des Problems finden jemand mir helfen ...Linq Abfrage erhält mehr Datensätze als SQL-Abfrage
SQL-Abfrage
select
DLId = p.Id,
TopicId = st.Id,
TopicName = at.Name,
PrimaryOrg = bo.BusinessUnit,
StatusId = ns.ID,
ModifiedBy = pa.LastName
from STopics st
join ATopics at on st.Id = at.Id
join Students p on st.StudentId = p.Id
join Sorgs sbu on at.BUorgID = sbu.BUOrgID
join BOrgs bo on sbu.BUOrgID = bo.ID
join Status ns on st.SID = ns.ID
join Students pa on st.NominatedBy = pa.Email
where p.IsActive = 1 and sbu.StudentID = 123 and sbu.IsActive = 1
und die Linq-Abfrage ist
(from st in Context.STopics
join at in Context.ATopics on st.Id equals at.Id
join p in Context.Students on st.StudentId equals p.Id
join sbu in Context.Sorgs on at.BUorgID equals sbu.BUOrgID
join bo in Context.BOrgs on sbu.BUOrgID equals bo.ID
join ns in Context.Status on st.SID equals ns.ID
join pa in Context.Students on st.NominatedBy equals pa.Email
where p.IsActive==true && sbu.StudentID == 123 && sbu.IsActive == true
select new result()
{
DLId = p.Id,
TopicId = st.Id,
TopicName = at.Name,
PrimaryOrg = bo.BusinessUnit,
StatusId = ns.ID,
ModifiedBy = pa.LastName
})
StudentID <> TeilnehmerID –
sry, das war ein Tippfehler. korrigiert. – poc
Überprüfen Sie die [generierte SQL] (https://msdn.microsoft.com/en-us/library/bb386961%28v=vs.110%29.aspx) – Martheen