Hey,
I'm trying to change this:
uow.Session.CreateSQLQuery("select SUM(((hour(apt_to_hour) -
hour(apt_from_hour)) * 10000000 * 60 * 60 ) + ((Minute(apt_to_hour) -
minute(apt_from_hour)) * 10000000 * 60)) from calendar_appointments
where apt_crd_id = :studyCard").SetInt64("studyCard",
appointment.StudyCard.Id).UniqueResult();
sql query into QueryOver...
its getting the time difference (in ticks) between the apt_to_hour and
apt_from_hour (both are DateTime fields, named ToHour and FromHour)
i have tried doing something like this:
uow.Session.QueryOver<CalendarAppointment>()
.SelectList(list =>
(list.SelectSum(ca =>
((ca.ToHour.Hour -
ca.FromHour.Hour) * 10000000 * 60 * 60) +
((ca.ToHour.Minute -
ca.FromHour.Minute) * 10000000 *
60))))
.SingleOrDefault<Int64>();
but i get the felling its not the right way... probably because NH
yells at me with the following exception :
Could not determine member from (((((ca.ToHour.Hour -
ca.FromHour.Hour) * 10000000) * 60) * 60) + (((ca.ToHour.Minute -
ca.FromHour.Minute) * 10000000) * 60))
is there a way to create that query in a queryover? or i'm doomed to
stay with sql and magic strings? (don't care about HQL/Criteria since
its only 1 record fetching and not an N+1 records fetch which kills me
[in the matter of performance.. :)] and its not solving my magic
strings problem...)
thanks a lot,
Nadav Ben-Gal
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.