0
을이 사람은 작동하지 않습니다Linq에 where 절 - 비교 정수
var queryEH = from eh in entity.EmployeesHires where eh.ParentKey == item.PPYKey select eh;
foreach (var itemEH in queryEH)
{
var query = (from el in entity.EmployeeLeaves where el.HireID == itemEH.ID select el.Duration).Sum();
}
을이 하나가하는 반면 :
이var queryEH = from eh in entity.EmployeesHires where eh.ParentKey == item.PPYKey select eh;
foreach (var itemEH in queryEH)
{
var query = (from el in entity.EmployeeLeaves where el.HireID == 125 select el.Duration).Sum();
}
첫 번째에 예외는 다음과 같습니다
The cast to value type 'System.Int32' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.
'itemEH' 란 무엇이고'itemEH.ID'의 유형은 무엇입니까? –
가능한 복제가 [구체화 된 값이 null이므로 값 유형 'Int32'에 대한 캐스트가 실패했습니다.] (http://stackoverflow.com/questions/6864311/the-cast-to-value-type-int32-failed-because- the-materialized-value-is-null) –
@JonSkeet이 대답을 편집했습니다 – Jude