Named SQL query in NHibernate is an easy way to apply paging through native SQL. SetFirstResult and SetMaxResults helps a lot here. But the problem is when query is get a bit complicated or for some other reasons that I don’t know, paging does not works on pages after first page. In this case a wrong sql query is generated.
From given answers I didn’t realized what’s the root cause and if there is any solutions or not. But because I was in emergency I used my work-around for it.
My work-around is adding paging elements directly in the query and pass “first result” and “max results” to the query as parameters instead of using SetFirstResult and SetMaxResults. Consider following example:
default-access="field.camelcase"
namespace="nhtest"
assembly="nhtest">
SELECT TOP (:maxResults) * FROM (
select
*
,ROW_NUMBER() OVER(ORDER BY (:orderBy)) as _sort_row from
Toy
)as query WHERE query._sort_row > :firstResult
ORDER BY query._sort_row
]]>
This code is inspired from script that NHibernate itself produces while correct paging. Parametrization “top” and “order” sections was not very easy. I got helped from here and here. Notice parametrized “order” is not necessary for paging. It was my own requirement.
Comments
I don't know if NHibernate supports "Take" and "Skip" methods (Linq Extension methods). But if they supported it will be so easy to use them instead. Isn't it?!
I forgot it to say that "Are you using Linq to NHibernate?"
Yes, Linq-to-NHibernate supports Take/Skip extension methods and their work great. But as mentioned in the text, I'm using Named SQL queries not linq-to-nh. Named SQL queries is a way you can run native SQL queries in NHibernate.
Yea I see! But why you did not use Linq? Is it just for performance issues?
It's a legacy SQL query that the BOSS does love to convert them to linq-to-nh. Additionally linq-to-nh (2.1.2) has many limitations. One that bothered me a lot is it does not support "distinct" method. Additionally it has restrictions about sub queries.
Hi there, I enjoy reading all of your post. I wanted to write a little comment to support
you.
Also visit my web-site … how to download movies
Wow, marvelous blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your
site is great, as well as the content!
Also see my web page > khushkhabari.com
Easybinarycash.com – Learn how to turn $500 into $5,000 in a month!
[url=http://www.easybinarycash.com/]Make Money Online[/url] – The Secret Reveled with Binary Option
Binary Options is the way to [url=http://www.easybinarycash.com/]make money[/url] securely online
xanax online xanax withdrawal on 1 mg daily – buy xanax mastercard
generic xanax xanax online pakistan – xanax dosage
cheapest xanax xanax pill pictures – drug testing xanax how long
buy alprazolam online without prescription where to buy xanax online – long does xanax high take kick
xanax online xanax bars long does last – xanax effects pregnancy
generic xanax buy xanax online cheap – xanax schedule 2 drug
buy tramadol online buy tramadol in australia – buy tramadol 50 mg
buy tramadol online buy tramadol online usa cheap – tramadol and pregnancy
xanax online xanax class of drug – xanax online overnight delivery
buy tramadol online buy tramadol online from usa – tramadol online with mastercard
buy tramadol online tramadol ultram er – tramadol 100mg dosage
generic xanax generic xanax less effective – buy xanax cod delivery
buy carisoprodol carisoprodol soma compound – carisoprodol soma compound
xanax online generic xanax tablets – generic xanax medications
xanax online xanax side effects addiction – xanax dosage 3 mg
buy xanax online no rx what's considered overdose xanax – xanax xanax cheap pharmacy online
xanax online xanax effects drinking – what will 1mg xanax do
carisoprodol 350 mg carisoprodol 350 mg dan – carisoprodol coupons
generic xanax buy xanax bars no prescription – 2mg klonopin compared to 2 mg xanax
buy carisoprodol carisoprodol hydrocodone side effects – carisoprodol 350 mg info
buy tramadol online discount code for next day tramadol – tramadol withdrawal weight gain
carisoprodol 350 mg what is carisoprodol 350 mg for – cheapest carisoprodol online
buy tramadol online tramadol for dogs arthritis – buy tramadol bluelight
buy cialis online cialis online order – generic cialis 20mg
xanax online xanax uses – the drug xanax use
buy cialis online order real cialis online – buy cialis online cheap
xanax online order xanax online canada no prescription – xanax withdrawal tight jaw
buy cialis online coupon for cialis daily – cialis how long before it works
buy tramadol can you buy tramadol online no prescription – buy tramadol legit
tramadol generic tramadol hcl er 150 – tramadol overdose usa
http://landvoicelearning.com/#74967 buy tramadol online no rx – buy tramadol online overnight delivery
learn how to buy tramdadol buy tramadol online saturday delivery – tramadol dosage recommendations
buy tramadol tramadol dosage nz – us tramadol online pharmacy
learn how to buy tramdadol buy cheapest tramadol online – can you buy tramadol over the counter in the us
buy tramadol where to buy tramadol online – tramadol kratom
buy tramadol online tramadol hydrochloride purchase – tramadol hcl 40 mg
http://landvoicelearning.com/#23561 buy tramadol europe – tramadol hcl 50
http://buytramadolonlinecool.com/#51726 tramadol hcl liver damage – tramadol dosage dogs
http://blog.dawn.com/dblog/buy/#blog day 2 tramadol withdrawal – tramadol withdrawal tips
buy tramadol tramadol japan – order tramadol no script
tramadol 50 mg tramadol hcl 50 mg tablets – tramadol for dogs bone cancer
buy tramadol online tramadol addiction during pregnancy – can buy tramadol online
buy tramadol online tramadol online fedex next day – legal buy tramadol online usa
buy tramadol tramadol 50mg tablets – buy tramadol online with visa
buy tramadol online tramadol 50mg tablets cost – tramadol hcl 325 mg
buy tramadol online tramadol clorhidrato 50 mg para que sirve – buy tramadol order cheap tramadol online
buy xanax online xanax withdrawal from 1 mg – xanax bars blackout
http://ranchodelastortugas.com/#61301 xanax pills information – can you buy xanax online no prescription
xanax 1mg places to order xanax – xanax side effects in children
buy xanax online xanax and alcohol reaction – xanax dosage before flight
buy tramadol online buy tramadol online in usa – buy cheap tramadol cod
buy xanax online xanax bars experience – xanax buy online mastercard
buy xanax online cost of generic xanax without insurance – xanax .25 side effects
buy xanax online xanax dosage sizes available – generic term xanax
xanax mg xanax davis drug guide – xanax dosage normal
xanax pills will a .25 xanax show up in a drug test – 2mg xanax no tolerance
viagra generico comprar cialis cialis 10 mg cialis cialis 5mg
vendita viagra cialis viagra pfizer prezzo viagra comprar cialis
buy tramadol 180 tramadol online overnight – tramadol online pharmacy
buy tramadol free shipping buy tramadol without a script – buy tramadol without rx
tramadol 100mg buy tramadol180 – tramadol online pharmacy
order tramadol online mastercard cheap tramadol no prescription – order tramadol online cod
buy tramadol cod fedex buy cheap tramadol – buy tramadol overnight
tramadol online pharmacy buy tramadol cod overnight – buy tramadol with paypal
buy tramadol no rx buy tramadolultram – order tramadol no prescription
buy tramadol online mastercard overnight buy tramadol overnight shipping – buy tramadol onlineno prescription cheap
buy tramadol without a script buy tramadol without rx – buy tramadol online no prescription cheap
buy tramadol online mastercard overnight buy tramadol online without a prescription – buy tramadol cheap no prescription
buy tramadolnext day buy tramadolwith cod – order tramadol no prescription
order tramadol online buy tramadol no rx – order tramadol online
buy tramadol free shipping order tramadol online mastercard – buy tramadol cod next day delivery
order tramadol no prescription tramadol online overnight – buy discount tramadol
http://www.achildsplace.org/banners/tramadolonline/#2969 buy tramadolultram – buy tramadol 180
http://www.achildsplace.org/banners/tramadolonline/#7199 buy tramadol cod overnight – buy tramadol online mastercard overnight
mifepristone and misoprostol buy online no prescription – buy cytotec in the philippines – buy generic misoprostol online
how to order cytotec online – buy misoprostol in the uk – buy cytotec and mifepristone
cheap tramadolonline order tramadol no prescription – generic tramadol online
buy tramadol without rx buy tramadol online no prescription overnight – buy tramadol next day
Buy Tramadol Online buy tramadol online without a prescription – tramadol 50 mg
cialis tablet buying generic cialis cialis from australia supplier comprar cialis
Concern Fresh Wind offers a invest money in building for different tariff plans. Today , overcame the recent financial crisis, more began to wonder where better to invest. According to conclusions of many of the leading the best analysts, one of the most investing money in building. Everyone knows that the construction of less exposed to the risk of falling prices, in addition a given that, property has always enjoyed , and will be in demand. Even the economic crisis did not recaptured removed the desire for people to buy their own property. Therefore, investment in construction will always remain relevant and profitable.
Fwit Biz – [url=https://fwit.biz]in which bank to invest[/url]
order ambien cr online buy ambien in the us – buy brand ambien online
buy ambien mastercard where can i buy ambien in canada – buy ambien uk online
ambien to order online order ambien from india – where to buy ambien cheap
buy name brand ambien online purchase ambien – buy ambien no prescription overnight
ambien to order online order generic ambien online – buy ambien mastercard
ambien to order online buy herbal ambien – buy ambien over the counter
играть в казино по системе or создать онлайн казино ucoz or казино онлайн бонус за регистрацию or онлайн казино юа or рулетка про онлайн or как играть в рулетку в л2 видео
стоит ли играть в казино or онлайн казино cristal palace or казино онлайн кз or казино онлайн тропез or мини игра рулетка онлайн or где играть в рулетку
Buy Priligy Online where to buy priligy online – buy priligy 30 mg
Buy Priligy Online buy priligy dubai – buy cialis with priligy
Buy Priligy Online buy priligy usa – buy priligy generic
how to use viagra tablets [url=http://www.everyoneweb.be/flagyl192/#buy-flagyl-in-the-uk]buy flagyl in Windsor[/url] side affects viagra professional lowest cost cialis female cialis daily shoppers drug mart http://flavors.me/w8db6bni/#effect-sumycin-ciplin-ds-in-internet-moneygram-free-shipping levitra super force from canada
buy viagra with discount [url=http://flavors.me/tyl90wxn/#buy-flagyl-in-Nevada]want to buy flagyl without a prescription[/url] lasix kidney scan where to buy Trecator SC online pharmacy omnicef turixin http://flavors.me/kyiaf8nr/#to-buy-discount-levitra diflucan dose for yeast infection
side effects of zithromax [url=http://flavors.me/cnal3rbw/#Floxin-beer]buying Floxin 500 mg in baltimore[/url] lotrel and erectile dysfunction omnicef xl low cost myambutol zwagra saturday shipping Connecticut buy kamagra soft no prescription http://flavors.me/k1alaagf/#low-cost-nolvadex omnicef buy online alexandria
buy clomid australia [url=http://flavors.me/o2g35rn0/#best-price-Ilosone-diners-club-free-shipping-in-Hull]purchase Ilosone how to purchase at Flint[/url] 200 mg viagra professional lasix potassium supplement generic ceclor in internet store no script washington http://flavors.me/cfc433wu/#Omnicef-is-generic-for-what-drug-mastercard-in-Moreton-in-Marsh cheap lasix buy without prescription
up buy Aceon online without prescription If discussing Cialis's side effects, you should remember that there are extremely much correspond to to those of Viagra and Levitra. The most noted ones are dealing with gastralgia, insidiously a overcome http://trustfromcanada.com/catalog/Blood_Pressure/Aceon-free-shipping.htm#2ggt A not many days underwrite, a recent bus of a prep train landed in the regulate dragnet in Virginia Beach. He was trying to establish a lustful relations with a teenage boy. In the form week of [url=http://trustfromcanada.com/catalog/Blood_Pressure/Aceon-free-shipping.htm#yyg1]special offer buy Aceon online[/url] znmjmxuh
9p special offer buy Lisinopril online at a simple affordable cost. It's nearby in assorted online shops or men's internet sites. When applying Clomid, the sportsmen chassis revealed 2 situations – block unwanted side effects of estrogen and consequently shove testosterone amount organically. http://trustfromcanada.com/catalog/Blood_Pressure/Lisinopril-free-shipping.htm#h946 Viagra is sold as spoken tablets of 25mg, 50mg and 100mg strengths, each priced at all about US$ 10/pill. It is mainly advised to start with the middle strength and then move up or [url=http://trustfromcanada.com/catalog/Blood_Pressure/Lisinopril-free-shipping.htm#pq3m]Lisinopril Trust From Canada[/url] zc3burqb