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




Creates and executes an ObjectReader on the ObjectContext.

Syntax

Visual Basic (Declaration) 
Overloads Public Overridable Function GetObjectReader(Of T)() As ObjectReader(Of T)
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim value As ObjectReader(Of T)
 
value = instance.GetObjectReader(Of T)()
C# 
public virtual ObjectReader<T> GetObjectReader<T>()
Managed Extensions for C++ 
public: virtual ObjectReader<T>* GetObjectReader<T>(); 
C++/CLI 
public:
virtual ObjectReader<T>^ GetObjectReadergeneric<typename T>
(); 

Type Parameters

T

Return Value

An ObjectReader representing a forward-only cursor on the resultset.

Example

The following example introduces 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>(); 
  
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 is a 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