I'm pretty new to nhibernate... but we're running a lot of sql through it
Via our libraries. (I know that's not the best way, but we are converting step by step and we have a lot of custom sql in our apps)
But I have a piece of sql, which in nhibernate returns 0 rows, but in my sql
Tool returns rows galore.
I've tried running just the first half of the union and just the second half
Again nh = rows, sql tool 300 rows.
I've tried removing all the tab chars, no joy.
I've tried pulling out the extra spaces (yes I was that desperate) and that didn't do it.
I'm really stumped.
Can anyone eyeball it and see if I'm doing something obviously stupid?
Are there nhibernate gotchas that can cause this behavior?
Thanks
Cal-
SELECT top 300 svy_potential_call.svy_case_id,
case phone_type_cd
when 3882 then address.home_phone
when 3883 then address.work_phone
when 3884 then address.mobile_phone
end as phone_number,
case phone_type_cd
when 3882 then convert(varchar(10), 'home')
when 3883 then convert(varchar(10), 'work')
when 3884 then convert(varchar(10), 'mobile')
end as phone_type,
phone_type_cd,
'student' as who,
convert(varchar(150),
student.stud_lname) + ',
' + convert(varchar(150),
student.stud_fname) as person_name,
student.stud_id,
svy_potential_call_id,
svy_case.case_survey_end,
'(' + convert(varchar(5),svy_callback_priority.priority) + ') ' +
svy_callback_priority.name as priority_name,
svy_potential_call.svy_callback_priority_id,
svy_potential_call.last_mod_dt,
svy_potential_call.last_mod_user,
null as relationship_name
FROM svy_potential_call,
svy_callback_priority,
svy_case,
student,
address
WHERE (svy_potential_call.svy_callback_priority_id = svy_callback_priority.svy_callback_priority_id)
AND (svy_case.svy_case_id = svy_potential_call.svy_case_id)
AND (svy_case.stud_id = student.stud_id)
AND (student.address_id = address.address_id)
AND contact_id = null
AND case phone_type_cd when 3882 then address.home_phone when 3883 then address.work_phone when 3884 then address.mobile_phone end != null
AND svy_potential_call.call_in_process_flg = 'Y'
AND svy_potential_call.last_mod_dt <= dateadd(mi,
-90,
getdate())
union
SELECT top 300 svy_potential_call.svy_case_id,
case phone_type_cd
when 3882 then address.home_phone
when 3883 then address.work_phone
when 3884 then address.mobile_phone
end as phone_number,
case phone_type_cd
when 3882 then convert(varchar(10), 'home')
when 3883 then convert(varchar(10), 'work')
when 3884 then convert(varchar(10), 'mobile')
end as phone_type,
phone_type_cd,
'contact' as who,
convert(varchar(150),
contact.contact_lname) + ',
' + convert(varchar(150),
contact.contact_fname) as person_name,
svy_potential_call.contact_id,
svy_potential_call_id,
svy_case.case_survey_end,
'(' + convert(varchar(5), svy_callback_priority.priority) + ') ' +
svy_callback_priority.name as priority_name,
svy_potential_call.svy_callback_priority_id,
svy_potential_call.last_mod_dt,
svy_potential_call.last_mod_user,
relationship.code_desc as relationship_name
FROM svy_potential_call,
svy_callback_priority,
svy_case,
contact,
address,
code as relationship
WHERE (svy_potential_call.svy_callback_priority_id = svy_callback_priority.svy_callback_priority_id)
AND (svy_case.svy_case_id = svy_potential_call.svy_case_id)
AND (svy_potential_call.contact_id = contact.contact_id)
AND (contact.address_id = address.address_id)
AND (contact.contact_rel_cd = relationship.code_id)
AND svy_potential_call.contact_id != null
AND case phone_type_cd when 3882 then address.home_phone when 3883 then address.work_phone when 3884 then address.mobile_phone end != null
AND svy_potential_call.call_in_process_flg = 'Y'
AND svy_potential_call.last_mod_dt <= dateadd(mi, -90, getdate())