comparison HowTo/DataAccess/Delete.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
8 namespace HowTo.DataAccess
9 {
10 [TestFixture]
11 public class Delete
12 {
13 private int Insert()
14 {
15 using (DbManager db = new DbManager())
16 {
17 return db
18 .SetCommand(@"
19 INSERT INTO Person (
20 FirstName, LastName, Gender
21 ) VALUES (
22 @FirstName, @LastName, @Gender
23 )
24 SELECT Cast(SCOPE_IDENTITY() as int)",
25 db.Parameter("@FirstName", "Crazy"),
26 db.Parameter("@LastName", "Frog"),
27 db.Parameter("@Gender", "U"))
28 .ExecuteScalar<int>();
29 }
30 }
31
32 [Test]
33 public void Test1()
34 {
35 int id = Insert();
36
37 /*[a]*/SprocQuery<Person> query = new SprocQuery<Person>()/*[/a]*/;
38
39 query./*[a]*/DeleteByKey(id)/*[/a]*/;
40 }
41
42 [Test]
43 public void Test3()
44 {
45 int id = Insert();
46
47 using (DbManager db = new DbManager())
48 {
49 /*[a]*/SqlQuery<Person> query = new SqlQuery<Person>()/*[/a]*/;
50
51 Person person = query.SelectByKey(db, id);
52
53 query./*[a]*/Delete(db, person)/*[/a]*/;
54 }
55 }
56 }
57 }
58