Knight Data Access Layer
Performing Searches
Basic Tasks C# > Loading Data > Performing Searches

Performing Searches

Searching can be performed in several different ways in Knight Data Access Layer. 

 

Performing an Exact Search

The built in search mechanism will search for exact values that are not the default value.  By not setting a value, it will not be searched.

 

//Create a new Person to save to the database

Person currentPerson = new Person();

currentPerson.FirstName = "John";

currentPerson.LastName = "Smith";

 

//Get the current instance of the helper

IDataHelper db = DataHelper.SessionFactory();

 

//Save it to the database

db.Save(currentPerson);

 

//Search parameters

Person searchParm = new Person();

searchParm.FirstName = "John";

 

//Search for records based on the passed in search object

List<Person> personList = _db.Search<Person>(searchParm, 50);