tags:

views:

23

answers:

0

I am using looking to use a sub query in Nhibernate Criteria to check on the visibility of a row. I have created a subquery in sql that looks like this

select * from Visibility as b
where  **ProductID = a.id**
and SiteId in (129)
and ( Hide = 1
and (
    ((StartDate < GETDATE()) and (EndDate is null))
    or 
    ((EndDate > GETDATE()) and (StartDate is null))
    or 
    **((GETDATE() between StartDate and EndDate))**
    )
)
or ( Hide = 0
and (
    ((StartDate > GETDATE()) and (EndDate is null))
    or 
    ((EndDate < GETDATE()) and (StartDate is null))
    or 
    **(not(GETDATE() between StartDate and EndDate))**
    )
)

I am

I have been trying to work out how do I insert the product Id from the parent query into the Detached Criteria using Criteria?

Also how do I perform the (GETDATE() between StartDate and EndDate)? I can search between on a row, but not the other way around?

Any help will be apprecated.