Knight Data Access Layer
Search<T>(T,Int32,Int32) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > Search Method : Search<T>(T,Int32,Int32) Method
Generic class type
What to search for
The page of records to retrieve
The number of records per page
Search for records based on the passed in search object and page in the database
Syntax
Overloads Function Search(Of T As {Class, New})( _
   ByVal searchParameters As T, _
   ByVal page As Integer, _
   ByVal pageSize As Integer _
) As List(Of T)
Dim instance As IDataHelper
Dim searchParameters As T
Dim page As Integer
Dim pageSize As Integer
Dim value As List(Of T)
 
value = instance.Search(Of T)(searchParameters, page, pageSize)
List<T> Search<T>( 
   T searchParameters,
   int page,
   int pageSize
)
where T: class, new()
List<T*>* Search<T>( 
   T* searchParameters,
   int page,
   int pageSize
) 
where T: ref class, gcnew()
List<T^>^ Searchgeneric<typename T>
( 
   T^ searchParameters,
   int page,
   int pageSize
) 
where T: ref class, gcnew()

Parameters

searchParameters
What to search for
page
The page of records to retrieve
pageSize
The number of records per page

Type Parameters

T
Generic class type
Example
//Get the current thread static safe instance of the helper
IDataHelper db = DataHelper.SessionFactory();
 
//Specify User Name and License Key from the receipt, leave blank for trial mode
//db.UserName = "John Smith 1234";
//db.LicenseKey = "asdfl219==";
 
// Open the database connection
db.OpenConnection();
 
// Clear table Person
db.TruncateTable("Person");
 
// Create Persons to save to the database
List<Person> persons = new List<Person>
{
   new Person
       {
           FirstName = "Han",
           LastName = "Solo",
           PersonTypeId = 1
       },
   new Person
       {
           FirstName = "Luke",
           LastName = "Skywalker",
           PersonTypeId = 1
       },
   new Person
       {
           FirstName = "Leia",
           LastName = "Organa",
           PersonTypeId = 1
       },
   new Person
       {
           FirstName = "Obi-Wan",
           LastName = "Kenobi",
           PersonTypeId = 2
       },
   new Person
       {
           FirstName = "Padme",
           LastName = "Amidala",
           PersonTypeId = 1
       },
};
 
// Save them to the database 
db.Save(persons);
 
Person searchParameters = new Person { PersonTypeId = 1 };
 
var result = db.Search<Person>(searchParameters, 2, 2);
 
// Close the connection
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'Specify User Name and License Key from the receipt, leave blank for trial mode
'db.UserName = "John Smith 1234"
'db.LicenseKey = "asdfl219=="
 
' Open the database connection
db.OpenConnection()
 
' Clear table Person
db.TruncateTable("Person")
 
' Create Persons to save to the database
Dim persons As New List(Of Person)() From {
    New Person With {.FirstName = "Han", .LastName = "Solo", .PersonTypeId = 1},
    New Person With {.FirstName = "Luke", .LastName = "Skywalker", .PersonTypeId = 1},
    New Person With {.FirstName = "Leia", .LastName = "Organa", .PersonTypeId = 1},
    New Person With {.FirstName = "Obi-Wan", .LastName = "Kenobi", .PersonTypeId = 2},
    New Person With {.FirstName = "Padme", .LastName = "Amidala", .PersonTypeId = 1}}
 
' Save them to the database 
db.Save(persons)
 
Dim searchParameters As Person = New Person With {.PersonTypeId = 1}
 
Dim result = db.Search(Of Person)(searchParameters, 2, 2)
 
' Close the connection
db.CloseConnection()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IDataHelper Interface
IDataHelper Members
Overload List