T
Chili.Opf3 Send comments on this topic.
Generic GetObjectReader(IQuery) Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class > GetObjectReader Method : Generic GetObjectReader(IQuery) Method




query
An instance of a class that implements the IQuery interface. This query is compiled and used to retrieve the objects from the storage.
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)
C# 
public virtual ObjectReader<T> GetObjectReader<T>( 
   IQuery query
)
Managed Extensions for C++ 
public: virtual ObjectReader<T>* GetObjectReader<T>( 
   IQuery* query
) 
C++/CLI 
public:
virtual ObjectReader<T>^ GetObjectReadergeneric<typename T>
( 
   IQuery^ 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

This routine returns an ObjectReader that can be seen as forward-only cursor through the resultset. The ObjectReader allows you to go through the resultset object per object. Usually an ObjectReader is used in export or batch routines to minimize the memory amount.

Requirements

Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family

See Also