comparison HowTo/Data/ExecuteNonQuery.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 NUnit.Framework;
3 using BLToolkit.Data;
4
5 namespace HowTo.Data
6 {
7 using DataAccess;
8
9 [TestFixture]
10 public class ExecuteNonQuery
11 {
12 [Test]
13 public void Test()
14 {
15 Person person = new Person();
16
17 person.FirstName = "John";
18 person.LastName = "Smith";
19 person.Gender = Gender.Male;
20
21 using (DbManager db = new DbManager())
22 {
23 db.BeginTransaction();
24
25 // Execute.
26 //
27 db
28 .SetSpCommand("Person_Insert", db.CreateParameters(person))
29 ./*[a]*/ExecuteNonQuery/*[/a]*/();
30
31 // Check the result.
32 //
33 person = db
34 .SetCommand(
35 "SELECT * FROM Person WHERE LastName = @lastName",
36 db.Parameter("@lastName", "Smith"))
37 .ExecuteObject<Person>();
38
39 Assert.IsNotNull(person);
40
41 // Cleanup.
42 //
43 db
44 .SetCommand(
45 "DELETE FROM Person WHERE LastName = @lastName",
46 db.Parameter("@lastName", "Smith"))
47 ./*[a]*/ExecuteNonQuery/*[/a]*/();
48
49 db.CommitTransaction();
50 }
51 }
52 }
53 }