2 using System.Collections.Generic;
\r
6 using NUnit.Framework;
\r
7 using Test_NUnit.Linq_101_Samples;
\r
11 // test ns Linq_101_Samples
\r
13 namespace Test_NUnit_MySql.Linq_101_Samples
\r
15 namespace Test_NUnit_OracleODP.Linq_101_Samples
\r
17 namespace Test_NUnit_Oracle.Linq_101_Samples
\r
19 namespace Test_NUnit_PostgreSql.Linq_101_Samples
\r
21 namespace Test_NUnit_Sqlite.Linq_101_Samples
\r
23 namespace Test_NUnit_Ingres.Linq_101_Samples
\r
24 #elif MSSQL && MONO_STRICT
\r
25 namespace Test_NUnit_MsSql_Strict.Linq_101_Samples
\r
27 namespace Test_NUnit_MsSql.Linq_101_Samples
\r
29 namespace Test_NUnit_Firebird.Linq_101_Samples
\r
33 public class UnionAll_Union_Intersect : TestBase
\r
35 [Test(Description = "Concat - Simple. This sample uses Concat to return a sequence of all Customer and Employee phone/fax numbers.")]
\r
36 public void LinqToSqlUnion01()
\r
38 Northwind db = CreateDB();
\r
40 var q = (from c in db.Customers select c.Phone).Concat(
\r
41 from c in db.Customers select c.Fax).Concat(
\r
42 from e in db.Employees select e.HomePhone);
\r
44 var list = q.ToList();
\r
45 Assert.IsTrue(list.Count > 0);
\r
48 [Test(Description = "Concat - Compound. This sample uses Concat to return a sequence of all Customer and Employee name and phone number mappings.")]
\r
49 public void LinqToSqlUnion02()
\r
51 Northwind db = CreateDB();
\r
53 var q = (from c in db.Customers
\r
54 select new { Name = c.CompanyName, Phone = c.Phone })
\r
55 .Concat(from e in db.Employees
\r
56 select new { Name = e.FirstName + " " + e.LastName, Phone = e.HomePhone });
\r
58 var list = q.ToList();
\r
59 Assert.IsTrue(list.Count > 0);
\r
62 [Test(Description = "Union. This sample uses Union to return a sequence of all countries that either Customers or Employees are in.")]
\r
63 public void LinqToSqlUnion03()
\r
65 Northwind db = CreateDB();
\r
67 var q = (from c in db.Customers
\r
68 select c.Country).Union(from e in db.Employees
\r
71 var list = q.ToList();
\r
72 Assert.IsTrue(list.Count > 0);
\r
75 [Test(Description = "Intersect. This sample uses Intersect to return a sequence of all countries that both Customers and Employees live in.")]
\r
76 public void LinqToSqlUnion04()
\r
78 Northwind db = CreateDB();
\r
80 var q = (from c in db.Customers
\r
81 select c.Country).Intersect(from e in db.Employees
\r
84 var list = q.ToList();
\r
85 if (list.Count == 0)
\r
86 Assert.Ignore("Please check test validity");
\r
87 //Assert.IsTrue(list.Count > 0);
\r
90 [Test(Description = "Except. This sample uses Except to return a sequence of all countries that Customers live in but no Employees live in.")]
\r
91 public void LinqToSqlUnion05()
\r
93 Northwind db = CreateDB();
\r
95 var q = (from c in db.Customers
\r
96 select c.Country).Except(from e in db.Employees select e.Country);
\r
98 var list = q.ToList();
\r
99 Assert.IsTrue(list.Count > 0);
\r