I am facing problem, I write a query in Entity Framework Core using C#, but I am unable to get my final result. It will be great favour if someone help me.
I want to show students result of entry test, if subject result is not posted then it should show 0, means need to add left outer join. I write the below query, but when I execute it returns the error.
var result = _db.palSundayTests
.Where(w => w.testId == testId)
.Select(s => new
{
testId = s.testId,
testDate = s.testDate,
students = _db.palSundayTestStudents
.Where(w => w.testGroupId == s.testGroupId)
.Select(st => new
{
students = st,
results = (from tp in _db.palSubjInfo
join rs in _db.palStudentTestResult.Where(r => r.studentId == st.studentId)
on tp.subjectId equals rs.subjectId
into myres
from myview in myres.DefaultIfEmpty()
select new
{
myview.obtainedMarks
}).ToList()
}).FirstOrDefault(),
subjects = s.sundayTestTopic
});
When I run in POSTMAN, I get this error
The multi-part identifier "t.subjectId" could not be bound
The multi-part identifier "t.obtainedMarks" could not be bound
The multi-part identifier "t.studentId" could not be bound
The multi-part identifier "t.testId" could not be bound