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

Thread is closed for posting
1 posts, 0 answers
  1. Eugene
    Eugene avatar
    1 posts
    Member since:
    Dec 2012

    Posted 09 Jan 2018 Link to this post

    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.

     

Back to Top