comparison HowTo/DataAccess/OpenConfigQuery.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
3 using NUnit.Framework;
4
5 using BLToolkit.Data;
6 using BLToolkit.DataAccess;
7 using BLToolkit.Mapping;
8
9 namespace HowTo.DataAccess
10 {
11 [TestFixture]
12 public class OpenConfigQuery
13 {
14 public class Person
15 {
16 [MapField("PersonID"), PrimaryKey, NonUpdatable]
17 public int ID;
18
19 public string LastName;
20 public string FirstName;
21 public string MiddleName;
22 }
23
24 // /*[i]*/DbManager/*[/i]*/ is created by /*[i]*/SqlQuery/*[/i]*/.
25 //
26 [Test]
27 public void Test1()
28 {
29 SqlQuery<Person> query = new SqlQuery<Person>/*[a]*/()/*[/a]*/;
30
31 Person person = query.SelectByKey(1);
32
33 Assert.IsNotNull(person);
34 }
35
36 // /*[i]*/SqlQuery/*[/i]*/ takes /*[i]*/DbManager/*[/i]*/ as a parameter.
37 //
38 [Test]
39 public void Test2()
40 {
41 using (DbManager db = new DbManager())
42 {
43 SqlQuery<Person> query = new SqlQuery<Person>/*[a]*/(db)/*[/a]*/;
44
45 Person person = query.SelectByKey(1);
46
47 Assert.IsNotNull(person);
48 }
49 }
50
51 // /*[i]*/SqlQuery/*[/i]*/ method takes /*[i]*/DbManager/*[/i]*/ as a parameter.
52 //
53 [Test]
54 public void Test3()
55 {
56 using (DbManager db = new DbManager())
57 {
58 SqlQuery<Person> query = new SqlQuery<Person>/*[a]*/()/*[/a]*/;
59
60 Person person = query.SelectByKey(/*[a]*/db/*[/a]*/, 1);
61
62 Assert.IsNotNull(person);
63 }
64 }
65 }
66 }
67