using System;
using NUnit.Framework;
using BLToolkit.Data;
using BLToolkit.DataAccess;
namespace HowTo.DataAccess
{
[TestFixture]
public class Delete
{
private int Insert()
{
using (DbManager db = new DbManager())
{
return db
.SetCommand(@"
INSERT INTO Person (
FirstName, LastName, Gender
) VALUES (
@FirstName, @LastName, @Gender
)
SELECT Cast(SCOPE_IDENTITY() as int)",
db.Parameter("@FirstName", "Crazy"),
db.Parameter("@LastName", "Frog"),
db.Parameter("@Gender", "U"))
.ExecuteScalar<int>();
}
}
[Test]
public void Test1()
{
int id = Insert();
SprocQuery<Person> query = new SprocQuery<Person>();
query.DeleteByKey(id);
}
[Test]
public void Test3()
{
int id = Insert();
using (DbManager db = new DbManager())
{
SqlQuery<Person> query = new SqlQuery<Person>();
Person person = query.SelectByKey(db, id);
query.Delete(db, person);
}
}
}
} |