Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7862223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:02:54+00:00 2026-06-02T23:02:54+00:00

How to use union all in LINQ TO SQL. I have use the following

  • 0

How to use union all in LINQ TO SQL.
I have use the following code for union, then how to use this for union all?

List<tbEmployee> lstTbEmployee = obj.tbEmployees.ToList();
List<tbEmployee2> lstTbEmployee2 = (from a in lstTbEmployee
                                    select new tbEmployee2
                                    {
                                        eid = a.eid,
                                        ename = a.ename,
                                        age = a.age,
                                        dept = a.dept,
                                        doj = a.doj,
                                        dor = a.dor

                                    }).Union(obj.tbEmployee2s).ToList();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:02:57+00:00Added an answer on June 2, 2026 at 11:02 pm

    Concat is the LINQ equivalent of UNION ALL in SQL.

    I’ve set up a simple example in LINQPad to demonstrate how to use Union and Concat. If you don’t have LINQPad, get it.

    In order to be able to see different results for these set operations, the first and second sets of data must have at least some overlap. In the example below, both sets contain the word “not”.

    Open up LINQPad and set the Language drop-down to C# Statement(s). Paste the following into the query pane and run it:

    string[] jedi = { "These", "are", "not" };
    string[] mindtrick = { "not", "the", "droids..." };
    
    // Union of jedi with mindtrick
    var union =
      (from word in jedi select word).Union
      (from word in mindtrick select word);
    
    // Print each word in union
    union.Dump("Union");
    // Result: (Note that "not" only appears once)
    // These are not the droids...
    
    // Concat of jedi with mindtrick (equivalent of UNION ALL)
    var unionAll =
      (from word in jedi select word).Concat
      (from word in mindtrick select word);
    
    // Print each word in unionAll
    unionAll.Dump("Concat");
    // Result: (Note that "not" appears twice; once from each dataset)
    // These are not not the droids...
    
    // Note that union is the equivalent of .Concat.Distinct
    var concatDistinct =
      (from word in jedi select word).Concat
      (from word in mindtrick select word).Distinct();
    
    // Print each word in concatDistinct
    concatDistinct.Dump("Concat.Distinct");
    // Result: (same as Union; "not" only appears once)
    // These are not the droids...
    

    The result in LinqPad looks like this:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for this , i have many UNION ALL and how to use unpivot same
well i do not know how to use sql union properly . i have
How to rewrite this query NOT to use UNION (UNION ALL) clause: SELECT c
I have two select statements and make 'union all' for these two statements. Then,
I came across a scenario where I had to use Union all, how can
If I use a UNION to select columns from 5 tables, then select a
use this code, in the Preferences activity, to know when the reset preference has
I am trying to get recursive data. Following code returns all parents on the
Greetings! I want to use LINQ to query a list of objects and sort
I have a problem with the correct syntax to use UNION and GROUP_CONCAT in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.