Creates and executes an
ObjectReader on
the
ObjectContext.
Syntax
| Visual Basic (Declaration) | |
|---|
Overloads Public Overridable Function GetObjectReader(Of T)( _
ByVal query As IQuery _
) As ObjectReader(Of T) |
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As ObjectContext
Dim query As IQuery
Dim value As ObjectReader(Of T)
value = instance.GetObjectReader(Of T)(query)
|
Parameters
- query
-
An instance of a class that implements the
IQuery interface. This query is compiled and used
to retrieve the objects from the storage.
Type Parameters
- T
Return Value
An
ObjectReader representing a
forward-only cursor on the resultset.
Example
The following example introduces to the use of the GetObjectReader routine.
| C# | Copy Code |
|---|
// Creates a new ObjectContext that uses an MsSql Server as storage. ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "", "localhost", "application")); // ... Other code. // Gets all object matching the name and sorting them by name. // Returns the objects in an ObjectReader. ObjectReader<User> reader = context.GetObjectReader<User> ("Name like {0} SortBy Name Asc", "%mith%"); while(reader.Read()) { User user = reader.Current; // Do something. } // ObjectReader supports also foreach // foreach(User user in reader) // { // // Do something. // } |
Remarks
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also