0
|
1 using System;
|
|
2 using System.Linq;
|
|
3
|
|
4 using NUnit.Framework;
|
|
5
|
|
6 using BLToolkit.Data;
|
|
7 using BLToolkit.Data.Linq;
|
|
8
|
|
9 namespace Data.Linq
|
|
10 {
|
|
11 using Model;
|
|
12
|
|
13 [TestFixture]
|
|
14 public class LinqTest
|
|
15 {
|
|
16 class TestManager : DbManager
|
|
17 {
|
|
18 public Table<Person> Person
|
|
19 {
|
|
20 get { return GetTable<Person>(); }
|
|
21 }
|
|
22 }
|
|
23
|
|
24 [Test]
|
|
25 public void Test()
|
|
26 {
|
|
27 using (TestManager db = new TestManager())
|
|
28 {
|
|
29 var query = db.Person.Select(p => p);
|
|
30
|
|
31 var list = query.ToList();
|
|
32 }
|
|
33 }
|
|
34
|
|
35 Func<int, int> f;
|
|
36
|
|
37 void Func(System.Linq.Expressions.Expression<Func<int, int>> func, int n)
|
|
38 {
|
|
39 if (f == null)
|
|
40 f = func.Compile();
|
|
41
|
|
42 n = f(n);
|
|
43
|
|
44 Console.WriteLine(n);
|
|
45 }
|
|
46
|
|
47 void Foo(int i)
|
|
48 {
|
|
49 Func((n) => n + 2, i);
|
|
50 }
|
|
51
|
|
52 [Test]
|
|
53 public void Test2()
|
|
54 {
|
|
55 Foo(0);
|
|
56 Foo(1);
|
|
57 }
|
|
58 }
|
|
59 }
|