|
The SprocName attribute allows assigning a stored procedure name explicitly.
SprocName.cs
using System;
using System.Collections.Generic;
using NUnit.Framework;
using BLToolkit.DataAccess;
namespace HowTo.DataAccess
{
[TestFixture]
public class SprocName
{
public abstract class TestAccessor : DataAccessor
{
[SprocName("Person_SelectAll")]
public abstract List<Person> GetPersonList();
}
[Test]
public void Test()
{
TestAccessor ta = DataAccessor.CreateInstance<TestAccessor>();
List<Person> list = ta.GetPersonList();
Assert.AreNotEqual(0, list.Count);
}
}
} |
Person.cs
using System;
using BLToolkit.DataAccess;
using BLToolkit.Mapping;
namespace HowTo.DataAccess
{
public class Person
{
[MapField("PersonID"), PrimaryKey, NonUpdatable]
public int ID;
public string LastName;
public string FirstName;
public string MiddleName;
public Gender Gender;
}
} |
Gender.cs
using System;
using BLToolkit.Mapping;
namespace HowTo.DataAccess
{
public enum Gender
{
[MapValue("F")] Female,
[MapValue("M")] Male,
[MapValue("U")] Unknown,
[MapValue("O")] Other
}
} |
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add
key = "ConnectionString"
value = "Server=.;Database=BLToolkitData;Integrated Security=SSPI"/>
</appSettings>
</configuration> |
Create.sql script
| |