diff HowTo/DataAccess/ActionName.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HowTo/DataAccess/ActionName.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,38 @@
+using System;
+using NUnit.Framework;
+using BLToolkit.DataAccess;
+
+namespace HowTo.DataAccess
+{
+	[TestFixture]
+	public class ActionName
+	{
+		public abstract class PersonAccessor : DataAccessor<Person, PersonAccessor>
+		{
+			// Default action name is 'SelectByKey'.
+			// Stored procedure name is 'Person_SelectByKey'.
+			//
+			public abstract Person SelectByKey(int @id);
+
+			// Explicit action name is 'SelectByName'.
+			// Stored procedure name is 'Person_SelectByName'.
+			//
+			[/*[a]*/ActionName/*[/a]*/(/*[a]*/"SelectByName"/*[/a]*/)]
+			public abstract Person /*[a]*/AnyName/*[/a]*/    (string @firstName, string @lastName);
+		}
+
+		[Test]
+		public void Test()
+		{
+			PersonAccessor pa = /*[a]*/PersonAccessor.CreateInstance/*[/a]*/();
+
+			Person person1 = pa.SelectByKey(1);
+
+			Assert.IsNotNull(person1);
+
+			Person person2 = pa.AnyName(person1.FirstName, person1.LastName);
+
+			Assert.AreEqual(person1.ID, person2.ID);
+		}
+	}
+}