Knight Data Access Layer
Loading By Composite Key VB.NET
Basic Tasks VB.NET > Loading Data > Loading By Composite Key VB.NET

To load by a composite key, perform a LoadOne and pass in the composite values.

 

'Get the current instance of the helper

Dim db As IDataHelper = DataHelper.SessionFactory()

'Create a new Person to save to the database

Dim currentPerson As New Person()

currentPerson.FirstName = "John"

currentPerson.LastName = "Smith"


'Save it to the database

db.Save(currentPerson)

 

Dim parameters As New Dictionary(Of String,Object)()

parameters.Add("FirstName", "John")

parameters.Add("LastName", "Smith")

 

Dim personCopy As Person = db.LoadOne(Of Person)(parameters)