Use the Sql 2000 dialect

On Fri, Jan 30, 2009 at 4:39 PM, letov <[email protected]> wrote:

>
> My sample code:
>
>            var freeTicket1 = (from ticket in Session.Linq<Ticket>()
> where ticket.IsFree select ticket).FirstOrDefault();
>            var freeTicket2 = (Ticket)Session.CreateQuery("from Ticket
> ticket where ticket.IsFree=1").SetMaxResults(1).UniqueResult();
>            var freeTicket3 = (Ticket)Session.CreateCriteria(typeof
> (Ticket)).Add(Restrictions.Eq("IsFree", true)).SetMaxResults
> (1).UniqueResult();
>            return freeTicket1 ?? freeTicket2 ?? freeTicket3;
>
> SQL for all queries:
>
> SELECT   TOP 1 PK1_2_0_,
>               DT2_2_0_,
>               BLN3_2_0_
> FROM
>         (
>            SELECT ROW_NUMBER ( ) OVER ( ORDER BY
> __hibernate_sort_expr_0__ ) as
>                     row,
>                   query.PK1_2_0_,
>                   query.DT2_2_0_,
>                   query.BLN3_2_0_,
>                   query.__hibernate_sort_expr_0__
>            FROM
>                   (
>                      SELECT this_.PK_TICKET   as PK1_2_0_,
>                             this_.DT_CAPTURE  as DT2_2_0_,
>                             this_.BLN_FREE    as BLN3_2_0_,
>                             CURRENT_TIMESTAMP as
> __hibernate_sort_expr_0__
>                      FROM   COMMON.TBL_TICKET this_
>                      WHERE  this_.BLN_FREE = 1 /* @p0 */
>                   ) query
>         ) page
> WHERE    page.row > 0
> ORDER BY __hibernate_sort_expr_0__
>
>
> On 30 янв, 23:35, Tuna Toksoz <[email protected]> wrote:
> > .SetMaxResult() ?
> >
> > Tuna Toksözhttp://tunatoksoz.comhttp://twitter.com/tehlike
> >
> > Typos included to enhance the readers attention!
> >
> >
> >
> > On Fri, Jan 30, 2009 at 10:22 PM, letov <[email protected]> wrote:
> >
> > > Hello everyone.
> > > Is there a way to get pure "SELECT TOP" on sql server 2005, using hql
> > > or criteria api or nhibernate.linq?
> > > Thanks.- Скрыть цитируемый текст -
> >
> > - Показать цитируемый текст -
> >
>

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