2010-03-01 2 views
0

과 날짜를 비교 내가 시간 부분없이 날짜 시간 필드를 비교할 수있는 방법을는이 코드를 LINQ

The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported. 

감사합니다

+0

어떤 데이터베이스 시스템은 사용하는 것인가? – Gabe

답변

1

음이 확실히 그것을 할 수있는 가장 효율적인 방법이 아니다, 그러나 당신이 같은 시도 할 수 있습니다 :

i.SpesaVitto = db.TDP_NotaSpeseSezB.Where(p => p.GiornoFine == null && 
      (new DateTime((p.Giorno as DateTime).Year, (p.Giorno as DateTime).Month, (p.Giorno as DateTime).Day) == (new DateTime((i.Data as DateTime).Year, (i.Data as DateTime).Month, (i.Data as DateTime).Day) && 
      p.MissioneID == missioneID).Sum(p => p.Costo); 

요구 사항에 따라 좀 더 빠르고 깨끗하게 구현할 수 있지만 날짜가 데이터베이스에 저장되는 방식에 따라 달라집니다. 당신의 문제에 대한

0

체크 아웃이 question 구문 오류가 아닌 SQL에있을 수 있습니다. 당신 LINQ. 그 문제의 아스 커는 썼다 :

가 작성해야
SQL ------ 
Select 
EmployeeNameColumn 
From 
EmployeeTable 
WHERE StartDateColumn.Date <= GETDATE() //Today 
SQL ------ 

:

SQL ------ 
Select 
EmployeeNameColumn 
From 
EmployeeTable 
WHERE StartDateColumn <= GETDATE() //Today 
SQL -