Home

Getting a Oracle Exception

edited September 2012
I'm not sure if this a problem with how I have written the LINQ query or if it is a bug with LINQPad, but I have the following:
from system in MonitorSystems
select new
{
	Id = system.ID,
	Name = system.Name,
	Average = system.SystemRecords.Average(x => x.Measurement),
	LatestMeasurement = (from record in Records
						where record.SystemID == system.ID
						orderby record.ID descending
						select record).First().Measurement,
	Measurements = from record in system.SystemRecords
				   orderby record.RecordDate descending
				   select new
				   {
						Measurement = record.Measurement,
						RecordDate = record.RecordDate
				   }

}
It compiles fine, but I get a ORA-00933 error: SQL command not properly ended. This is the SQL it generates,
SELECT t2.SYSTEM_ID, t2.MEASUREMENT, t2.RECORD_DATE
FROM MONITOR_SYSTEM t0
OUTER APPLY (
  SELECT * FROM (SELECT t3.ID
  FROM RECORD t3
  WHERE (t3.SYSTEM_ID = t0.ID)
  ORDER BY t3.ID DESC) WHERE ROWNUM<=1
  ) t1
LEFT OUTER JOIN RECORD t2
  ON (t2.SYSTEM_ID = t0.ID)
ORDER BY t1.ID DESC, t2.RECORD_DATE DESC

Comments

Sign In or Register to comment.