Hi,

When i want to use OrderBy() with Skip() and Take() methods OrderBy is ommited and it's not included in SQL Query. How can I solve the problem?

Regards, Karol Wojtaszek

asked Feb 23 '11 at 07:09

Karol%20Wojtaszek's gravatar image

Karol Wojtaszek
40224

edited Mar 04 '11 at 18:23


2 Answers:

I'm 100% sure this shouldn't happen - there are multiple tests for this case.

Can you provide an exact LINQ query?

answered Feb 23 '11 at 07:32

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

edited Feb 23 '11 at 07:32

int x = (APage - 1) * APerPage;
var ex = _session.Query.All<Platnik>()
  .Where(p => p.Firma == FirmaFilter)
  .OrderBy(p => p.Dane.Indeks)
  .Skip(() => x)
  .Take(() => APerPage);

answered Feb 23 '11 at 07:38

Karol%20Wojtaszek's gravatar image

Karol Wojtaszek
40224

edited Feb 23 '11 at 13:37

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Even if I change the order it doesn't work:

_session.Query.All<Platnik>()
.Where(p => p.Firma == FirmaFilter)
.Take(() => APerPage)
.OrderBy(p => p.Dane.Indeks);
(Feb 23 '11 at 07:44) Karol Wojtaszek Karol%20Wojtaszek's gravatar image

Changing the order definitely shouldn't help here.

Could you also add executed SQL for this query (the first one)? You can use SQL profiler or DO4 logging to get it.

(Feb 23 '11 at 13:36) Alex Yakunin Alex%20Yakunin's gravatar image

I've tried to turn on logging with log4net and couldn't do it. I've added dlls and added to app.config: http://pastebin.com/KP5d4QFW

(Feb 24 '11 at 15:55) Karol Wojtaszek Karol%20Wojtaszek's gravatar image

Hello Karol,

Which version of DataObjects.Net you are using? It could be 4.3.x or 4.4.

(Feb 25 '11 at 11:25) Dmitri Maximov Dmitri%20Maximov's gravatar image

It's lastest 4.4 build

(Feb 25 '11 at 14:47) Karol Wojtaszek Karol%20Wojtaszek's gravatar image

Karol, I've updated the configuration file you posted, now it uses the internal logging mechanism, which is simpler.

Could you please try once more? Thanks.

(Feb 25 '11 at 15:16) Dmitri Maximov Dmitri%20Maximov's gravatar image

Problem is connected with dot and subproperties (p.Dane is a structure). When I OrderBy with e.g. p.Id, it's ordering correctly

(Feb 26 '11 at 04:47) Karol Wojtaszek Karol%20Wojtaszek's gravatar image

OK, we'll check this scenario.

(Mar 01 '11 at 05:35) Dmitri Maximov Dmitri%20Maximov's gravatar image

Hello Karol,

Unfortunately, we failed to reproduce the issue. Could you send us the test case? The e-mail is: support [at] x-tensive.com.

Thanks.

(Mar 05 '11 at 08:34) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA