Knight Data Access Layer
Unit of Work Pattern VB.NET
Basic Tasks VB.NET > Patterns > Unit of Work Pattern VB.NET

The unit of work pattern wraps a set of database operations in a transaction. 

 

'Get the current instance of the helper

Dim db As IDataHelper = DataHelper.SessionFactory()

  

Using TempUnitOfWork As UnitOfWork = New UnitOfWork(db)

db.ExecuteNonQuery("INSERT INTO Customers (FirstName,LastName) VALUES ('John','Smith')")

db.ExecuteNonQuery("INSERT INTO Customers (FirstName,LastName) VALUES ('John','Doe')")

End Using