ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid's paging and incorrect query
Title:
B
I
{code}
?
I use code for Grid: public ActionResult ProductGetItems(GridParams g, string search) { ... var query = meta.Warehouse ... .Distinct(); return Json(new GridModelBuilder<...>(query, g) { Map = o => new { ... }, }.Build(), JsonRequestBehavior.AllowGet); } in sql-profiler I see two queries: 1) exec sp_executesql N'SELECT DISTINCT TOP(@p2) [LPA_L1].[OrderId] ... 2) exec sp_executesql N'SELECT TOP(@p2) COUNT(*) AS [LPAV_] FROM (SELECT [LPA_L3].[OrderId]... in second query DISTINCT is not exist, therefore paging is not correct. Why is this so?
Save Changes
Cancel
yura
asked at 04 Dec 2014
try doing the same query without the grid and see if it works the way you intended
at 04 Dec 2014
Omu
the query works, as I understand for paging GridModelBuilder construct query itself
at 04 Dec 2014
yura
it works if I use: var query = meta.Warehouse ....Distinct().Select(o=>new{...});
at 04 Dec 2014
yura
you can follow this demo http://demo.aspnetawesome.com/GridDemo/CustomQuerying if you want full control over the query, (to tell the GridModelBuilder not to do any querying you have to set the PageCount parameter on it)
at 04 Dec 2014
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK