T
Chili.Opf3 Send comments on this topic.
Generic ObjectReader Class
See Also  Members   Example 
Chili.Opf3 Namespace : Generic ObjectReader Class




Provides a way of reading a forward-only stream of objects from a data source.

Object Model

Syntax

Visual Basic (Declaration) 
Public MustInherit Class ObjectReader(Of T) 
   Inherits MarshalByRefObject
Visual Basic (Usage)Copy Code
Dim instance As ObjectReader(Of T)
C# 
public abstract class ObjectReader<T> : MarshalByRefObject 
Managed Extensions for C++ 
public __gc abstract class ObjectReader<T> : public MarshalByRefObject 
C++/CLI 
generic<typename T>
public ref class ObjectReader abstract : public MarshalByRefObject 

Type Parameters

T

Example

C#Copy Code
            [Persistent("USER")] 
public class User 

    private string _name = null; 
 
    [Field("NAME")] 
    public string Name 
    { 
        get { return _name; } 
        set { _name = value; } 
    } 
 
    // ... Other properties and fields. 

 
// ... Other code 
 
List<User> userList = new List<User>(); 
// Loads an ObjectReader of User from the storage and sorts the result set. 
using(ObjectReader<User> reader = context.GetObjectReader<User> 
    ("UserName like {0} SortBy UserName Asc", "%mit%")) 

    // Loop until we get objects. 
    while (reader.Read()) 
    { 
        User user = reader.Current; 
         
        if (user.Name == "Smith") 
            userList.Add(user); 
    } 
 
    // ObjectReader supports also foreach. 
    // foreach(User user in reader) 
    // { 
    //        // .. do something. 
    // } 

    

Remarks

To create an ObjectReader you must call the GetObjectReader method of the ObjectContext rather than directly using a constructor.

While the ObjectReader is in use and a transaction is opened on the associated ObjectContext the context is blocked and can not serve any other purpose until the ObjectReader is closed. If no transaction is opened the ObjectContext is free to serve any other request. Each opened ObjectReader should be closed immediately after having finished using it. It is recommended to use in CS the "using" statement when working with the ObjectReader or call immediately Close after having retrieved the required data (objects).

Changes made to a resultset by another process or thread while data is being read may be visible to the user of the ObjectReader. However, the precise behavior is timing dependent.

IsClosed, HasObjects and FinishedReading are the only properties that can be called after closing the ObjectReader.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      Chili.Opf3.ObjectReader

Requirements

Namespace: Chili.Opf3

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Chili.Opf3 (in Chili.Opf3.dll)

See Also