Ken, let me further explain my situation.

I have a database where there is an entity called Task with a
one-to-many relationship to TaskStatusHistory.  The current status of
the Task is determined by the TaskStatusHistory associated it with the
latest CreatedAt date.

I need to query for a Task by this 'current status' concept along with
other criteria as a part of the search.

I usually use NHQG to do my queries, but I don't think I'll be able to
here.  I'd still like to use the criteria API.

My query might look like this in Linq to Sql:
(from task in tasks
 from history in task.TaskStatusHistory.OrderBy(x => x.CreatedAt)
 where history.Status == DesiredStatus
 select task).Last()

I had this in NHQG as
Where.Task.TaskStatusHistory.With().Status.Eq(DesiredStatus), but
obviously that pulls back any Task that has ever had the DesiredStatus
and I can't figure out quite where to go from there.

I know how to use criteria API to do the order and select one if I
were querying directly on TaskStatusHistory and knew which task I was
interested in.  However, I have to filter based upon other criteria
for the Task as well, and I want to do it all in one query.

Thanks for your help.


On Sat, Nov 1, 2008 at 9:59 AM, Ken Egozi <[EMAIL PROTECTED]> wrote:
> new thing every day ...
> anyway, as I said you can ORDER BY and select the first row
>
> On Sat, Nov 1, 2008 at 4:52 PM, Nathan Stott <[EMAIL PROTECTED]> wrote:
>>
>> http://www.w3schools.com/Sql/sql_func_last.asp
>>
>> On Sat, Nov 1, 2008 at 1:45 AM, Ayende Rahien <[EMAIL PROTECTED]> wrote:
>> > What is Last ?
>> >
>> > On Sat, Nov 1, 2008 at 8:32 AM, Nathan Stott <[EMAIL PROTECTED]> wrote:
>> >>
>> >> Is there an equivalent to the SQL Last() in NHibernate criteria or HQL?
>> >>
>> >> As in SELECT LAST(column_name) FROM table_name
>> >>
>> >>
>> >
>> >
>> > >
>> >
>>
>>
>
>
>
> --
> Ken Egozi.
> http://www.kenegozi.com/blog
> http://www.musicglue.com
> http://www.castleproject.org
> http://www.gotfriends.co.il
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to