Knight Data Access Layer
CreateQuery<T> Method (DataHelper)
Example 




KellermanSoftware.NetDataAccessLayer Namespace > DataHelper Class : CreateQuery<T> Method
Generic class type
Create a LINQ query using an enhanced version of the IQToolkit
Syntax
Public Function CreateQuery(Of T)() As IQueryable(Of T)
Dim instance As DataHelper
Dim value As IQueryable(Of T)
 
value = instance.CreateQuery(Of T)()
public IQueryable<T> CreateQuery<T>()
public: IQueryable<T*>* CreateQuery<T>(); 
public:
IQueryable<T^>^ CreateQuerygeneric<typename T>
(); 

Type Parameters

T
Generic class type
Example
//Create a new Person to save to the database
Person person = new Person
{
    FirstName = "Greg",
    LastName = "Smith",
    DateCreated = DateTime.Now.Date
};
 
//Get the current instance of the helper 
IDataHelper db = DataHelper.SessionFactory();
 
//Save it
db.Save(person);
 
var query = db.CreateQuery<Person>();
var persons = query.Where(o => o.FirstName == "Greg");
'Create a new Person to save to the database
Dim person As Person = New Person With {.FirstName = "Greg", .LastName = "Smith", .DateCreated = Date.Now.Date}
 
'Get the current instance of the helper 
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'Save it
db.Save(person)
 
Dim query = db.CreateQuery(Of Person)()
Dim persons = query.Where(Function(o) o.FirstName = "Greg")
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

DataHelper Class
DataHelper Members