.AddObject()를 사용하여 데이터를 내 엔터티 테이블에 삽입하고 있습니다. 객체는 엔티티 테이블의 유형입니다. 객체는 eventStudent이며 eventStudent.ID 문자열, bool eventStudent.StudentPresent, bool eventStudent.ParentPresent가 있습니다.부울을 반환하는 Linq 쿼리
학생들은 학생 ID가 포함 된 문자열 목록입니다. 이벤트에서의 참석은 참석자라는 다른 객체에 있으며, 이는 studentID 문자열, bool studentPresent 및 bool parentPresent로 구성됩니다. StudentPresent 및/또는 ParentPresent에 해당하는 학생 ID 만 참석자 목록에 있습니다. eventStudent 객체를로드 할 때 StudentPresent 및 ParentPresent를 설정해야합니다. 이것은 내가 생각 해낸 것입니다 :
foreach (StudentMinimum student in students)
{
eventStudent.StudentPresent = (from a in attendees
where a.StudentID.Contains(student.StudentID)
&& a.StudentPresent
select a.StudentPresent);
}
내가 암시 내 쿼리를 개선 할 수있는 방법 '부울'
을에 유형 'System.Collections.Generic.IEnumerable을'변환 할 수 없습니다 오류 를받을 eventStudent 그래서 .StudentPresent가 True 또는 False로 설정되어 있습니까?
쿼리 끝 부분에 .FirstOrDefault()를 넣으십시오. – Rodders
빙고! 고마워. – Jazzy
멋지 네요, 나는 적절한 대답을 게시 할 것입니다. – Rodders