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();
Concatis the LINQ equivalent ofUNION ALLin SQL.I’ve set up a simple example in LINQPad to demonstrate how to use
UnionandConcat. 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:
The result in LinqPad looks like this: