One of the exciting things about Knight Data Access Layer is the ability to automatically map the results of a SQL query. This can be performed by simply creating a class to populate the results. Just like the other automatic mapping, the mappings are internally cached for high performance.
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
sql As String = "select * from Person where FirstName=@FirstName and LastName=@LastName"'Creating dictionary
Dim
parms As New Dictionary(Of String, Object)()parms.Add(
"FirstName", "John")parms.Add(
"LastName", "Smith")'Load the passed sql into a list of objects
Dim
personList As List(Of Person) = db.Load(Of Person)(sql, parms)