He intentado hacer funcionar la siguiente consulta durante unas horas y me estoy quedando sin ideas. ¿Alguien puede ver dónde me estoy equivocando? Cualquier puntero muy apreciado.Devuelve una lista de objetos tipeados a través de CreateSQLQuery en NHibernate
CalEvents = (List<CalEvent>)session.CreateSQLQuery(@"
SELECT *
FROM dbo.tb_calendar_calEvents
INNER JOIN dbo.tb_calEvents
ON (dbo.tb_calendar_calEvents.calEventID = dbo.tb_calEvents.id)
WHERE dbo.tb_calendar_calEvents.calendarID = 'theCalID'"
)
.AddEntity(typeof(CalEvent))
.SetInt64("theCalID", cal.id);
Error:
Kanpeki.NUnit.CalUserTest.Should_return_logged_in_user: System.ArgumentException : Parameter theCalID does not exist as a named parameter in [SELECT * FROM dbo.tb_calendar_calEvents INNER JOIN dbo.tb_calEvents ON (dbo.tb_calendar_calEvents.calEventID = dbo.tb_calEvents.id) WHERE dbo.tb_calendar_calEvents.calendarID = 'theCalID']
Gracias. que me hizo pasar un problema ahora estoy recibiendo System.InvalidCastException: no se puede convertir el objeto del tipo 'NHibernate.Impl.SqlQueryImpl' para escribir 'System.Collections.Generic.List'1 [Kanpeki.Domain.CalEvent] '. – user17510
Debería estar llamando .List() al final – gregmac