comparison UnitTests/Linq/UserTests/LetTest.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Linq.Expressions;
5
6 using BLToolkit.Data.Linq;
7 using BLToolkit.Mapping;
8
9 using NUnit.Framework;
10
11 namespace Data.Linq.UserTests
12 {
13 [TestFixture]
14 public class LetTest : TestBase
15 {
16 class Table1
17 {
18 public int Field3;
19 public int? Field5;
20
21 [Association(ThisKey="Field5", OtherKey="Field3", CanBeNull=true)]
22 public Table1 Ref1 { get; set; }
23
24 [Association(ThisKey="Field3", OtherKey="Field3", CanBeNull=true)]
25 public List<Table3> Ref2 { get; set; }
26 }
27
28 class Table2
29 {
30 public int? Field6;
31
32 [Association(ThisKey = "Field6", OtherKey = "Field6", CanBeNull = true)]
33 public Table3 Ref3 { get; set; }
34 }
35
36 class Table3
37 {
38 public int? Field6;
39 public int Field3;
40 public int Field4;
41
42 [Association(ThisKey="Field3", OtherKey="Field3", CanBeNull=true)]
43 public Table1 Ref4 { get; set; }
44
45 [Association(ThisKey="Field4", OtherKey="Field4", CanBeNull=true)]
46 public Table7 Ref5 { get; set; }
47
48 [Association(ThisKey = "Field6", OtherKey = "Field6", CanBeNull = true)]
49 public List<Table2> Ref9 { get; set; }
50 }
51
52 class Table7
53 {
54 public int Field4;
55 public string Field8;
56 }
57
58 [Test]
59 public void LetTest1()
60 {
61 using (var repository = new TestDbManager())
62 {
63 var q =
64 from t1 in repository.GetTable<Table2>()
65 from t2 in
66 from t5 in t1.Ref3.Ref4.Ref1.Ref2
67 let t3 = t1.Ref3
68 where t3.Ref5.Field8 == t5.Ref5.Field8
69 from t4 in t5.Ref9
70 select t4
71 select t1;
72
73 var linqResult = q.ToString();
74 }
75 }
76
77 [Test]
78 public void LetTest2()
79 {
80 using (var repository = new TestDbManager())
81 {
82 var q =
83 from t1 in repository.GetTable<Table2>()
84 from t2 in
85 from t5 in t1.Ref3.Ref4.Ref1.Ref2
86 let t3 = t1.Ref3
87 where t3.Ref5 == t5.Ref5
88 from t4 in t5.Ref9
89 select t4
90 select t1;
91
92 var linqResult = q.ToString();
93 }
94 }
95 }
96 }