Mercurial > pub > bltoolkit
comparison HowTo/DataAccess/ActionSprocName.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.DataAccess; | |
| 4 | |
| 5 namespace HowTo.DataAccess | |
| 6 { | |
| 7 [TestFixture] | |
| 8 public class ActionSprocName | |
| 9 { | |
| 10 [/*[a]*/ActionSprocName/*[/a]*/("GetByName", "Person_SelectByName")] | |
| 11 public class Person | |
| 12 { | |
| 13 public int PersonID; | |
| 14 public string LastName; | |
| 15 public string FirstName; | |
| 16 public string MiddleName; | |
| 17 } | |
| 18 | |
| 19 public abstract class PersonAccessor : DataAccessor | |
| 20 { | |
| 21 // Default action name is 'SelectByKey'. | |
| 22 // Stored procedure name is 'Person_SelectByKey'. | |
| 23 // | |
| 24 public abstract Person SelectByKey(int @id); | |
| 25 | |
| 26 // Default action name is 'GetByName'. | |
| 27 // Stored procedure name is 'Person_SelectByName' | |
| 28 // defined by the ActionSprocName attribute of the Person class. | |
| 29 // | |
| 30 public abstract Person GetByName(string @firstName, string @lastName); | |
| 31 } | |
| 32 | |
| 33 [Test] | |
| 34 public void Test() | |
| 35 { | |
| 36 PersonAccessor pa = /*[a]*/DataAccessor/*[/a]*/./*[a]*/CreateInstance/*[/a]*/<PersonAccessor>(); | |
| 37 | |
| 38 Person person1 = pa.SelectByKey(1); | |
| 39 | |
| 40 Assert.IsNotNull(person1); | |
| 41 | |
| 42 Person person2 = pa.GetByName(person1.FirstName, person1.LastName); | |
| 43 | |
| 44 Assert.AreEqual(person1.PersonID, person2.PersonID); | |
| 45 } | |
| 46 } | |
| 47 } |
