This is a migrated thread and some comments may be shown as answers.

How to force "union" sql request (is it supported)?

0 Answers 118 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eugene
Top achievements
Rank 1
Eugene asked on 09 Jan 2018, 11:22 AM

Hello,

 

I have table 'AppLanguages' and have made simple IQueryable request:

            var q1 = dataContext.AppLanguages.Take(3);
            var q2 = dataContext.AppLanguages.Skip(3).Take(2);
            var count = q1.Union(q2).Count();

But SQL Profiler shows 2 requests:

@__TAKE=3
SELECT  TOP(@__TAKE) a.[Id] AS COL1, a.[Code] AS COL2, a.[Descr] AS COL3, a.[IsActive] AS COL4 FROM [AppLanguages] a

@__TAKE=5,@__SKIP=3
WITH __OAPAGED AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY @@SPID) AS OA_ROWNUM FROM (
SELECT  TOP(@__TAKE) a.[Id] AS COL1, a.[Code] AS COL2, a.[Descr] AS COL3, a.[IsActive] AS COL4 FROM [AppLanguages] a
 ) AS __OATMPSET ) SELECT * FROM __OAPAGED WHERE [OA_ROWNUM] > @__SKIP AND [OA_ROWNUM] <= @__TAKE ORDER BY [OA_ROWNUM] ASC

1) Does DataAccess support LINQ Union

2) Is there any workaround to make it work in 1 request?

I found this article

https://docs.telerik.com/data-access/developers-guide/linq-support/data-access-feature-ref-linq-support-querying-query-operaions

and it looks like it should work. But it doesn't.

There's also an open issue:

https://feedback.telerik.com/Project/114/Feedback/Details/167605-make-union-linq-db-driven

Thanks in advance.

 

Tags
LINQ (LINQ specific questions)
Asked by
Eugene
Top achievements
Rank 1
Share this question
or