0
|
1 using System;
|
|
2 using System.Linq;
|
|
3
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 namespace Data.Linq
|
|
7 {
|
|
8 [TestFixture]
|
|
9 public class MultipleQuery : TestBase
|
|
10 {
|
|
11 //[Test]
|
|
12 public void Test1()
|
|
13 {
|
|
14 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = true;
|
|
15
|
|
16 ForEachProvider(db => AreEqual(
|
|
17 from p in Parent select p.Children,
|
|
18 from p in db.Parent select p.Children));
|
|
19
|
|
20 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = false;
|
|
21 }
|
|
22
|
|
23 //[Test]
|
|
24 public void Test2()
|
|
25 {
|
|
26 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = true;
|
|
27
|
|
28 ForEachProvider(db => AreEqual(
|
|
29 from p in Parent select p.Children.ToList(),
|
|
30 from p in db.Parent select p.Children.ToList()));
|
|
31
|
|
32 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = false;
|
|
33 }
|
|
34
|
|
35 [Test]
|
|
36 public void Test3()
|
|
37 {
|
|
38 ForEachProvider(db => AreEqual(
|
|
39 from p in Parent select Child,
|
|
40 from p in db.Parent select db.Child));
|
|
41 }
|
|
42
|
|
43 //[Test]
|
|
44 public void Test4()
|
|
45 {
|
|
46 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = true;
|
|
47
|
|
48 ForEachProvider(db => AreEqual(
|
|
49 from p in Parent select p.Children.Select(c => c.ChildID),
|
|
50 from p in db.Parent select p.Children.Select(c => c.ChildID)));
|
|
51
|
|
52 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = false;
|
|
53 }
|
|
54
|
|
55 [Test]
|
|
56 public void Test5()
|
|
57 {
|
|
58 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = true;
|
|
59
|
|
60 ForEachProvider(db =>
|
|
61 AreEqual(
|
|
62 from ch in Child
|
|
63 orderby ch.ChildID
|
|
64 select Parent.Where(p => p.ParentID == ch.Parent.ParentID).Select(p => p),
|
|
65 from ch in db.Child
|
|
66 orderby ch.ChildID
|
|
67 select db.Parent.Where(p => p.ParentID == ch.Parent.ParentID).Select(p => p)));
|
|
68
|
|
69 BLToolkit.Common.Configuration.Linq.AllowMultipleQuery = false;
|
|
70 }
|
|
71 }
|
|
72 }
|