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




Represents a databindable, customized view of an ObjectSet for sorting, filtering, searching, editing, and navigation.

Syntax

Visual Basic (Declaration) 
Public NotInheritable Class ObjectView(Of T) 
Visual Basic (Usage)Copy Code
Dim instance As ObjectView(Of T)
C# 
public sealed class ObjectView<T> 
Managed Extensions for C++ 
public __gc __sealed class ObjectView<T> 
C++/CLI 
generic<typename T>
public ref class ObjectView sealed 

Type Parameters

T

Example

The following example shows how to use the ObjectView in an application.
C#Copy Code
             [Persistent("USER")] 
public class User 

                    private int _id; 
                    private string _name; 
 
                    [Field("ID", AutoNumber = true, AllowDBNull = false, Identifier = true)] 
                    public int ID 
                    { 
                        get { return _id; } 
                        set { _id = value; } 
                    } 
 
                    [Field("NAME")] 
                    public string Name 
                    { 
                        get { return _name; } 
                        set { _name = value; } 
                    } 
 
                    // ... Other properties and fields. 

 
// ... Other code 
 
// Loads an ObjectSet of User from the storage and sorts the result descending. 
ObjectSet<User> objectSet = context.GetObjectSet<User>(); 
 
// Create a new BindingSource. 
BindingSource bindingSource = new BindingSource(); 
// Associate the ObjectSet with the DataSource. The ObjectView of the ObjectSet's DefaultView  
// property is used when binding an ObjectSet as data source. 
bindingSource.DataSource = objectSet; 
// Add a sort string to sort the ObjectView. 
bindingSource.Sort = "[ID] ASC, [NAME] DESC"; 
// Bind the BindingSource to a visual DataGridView. 
dataGridView1.DataSource = bindingSource; 
 
// Create a new instance of the DataView and set the current ObjectSet as 
// associated ObjectSet. 
DataView dataView = new DataView(objectSet); 
// Sort by the name property in ascending order. 
dataView.Sort = "[NAME]"; 
 
// Loop over all items in the DataView. The items are sorted by the name property. 
foreach(User user in dataView) 

                    // Do something with the persistent. 

                    

Remarks

The ObjectView represents a databindable and customized view of an ObjectSet. The class allows sorting, filtering, searching, editing and navigation in/of the data of the associated ObjectSet.

The class' content may be customized by specifiying a sort or a filter expression. This class may be also bound to a DataGrid, BindingSource or other data-driven controls. The ObjectSet returns an instance of this class when querying the DefaultView property.

When sorting or filtering the ObjectView the data of the associated ObjectSet is not affected at all. Each ObjectSet may also be associated with more then one ObjectView. All ObjectViews are then updated instantely when updating the ObjectSet.

Inheritance Hierarchy

System.Object
   Chili.Opf3.ObjectView

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