T
Chili.Opf3 Send comments on this topic.
Generic GetObjectSet(IQuery,Int32) Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class > GetObjectSet Method : Generic GetObjectSet(IQuery,Int32) 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.
amount
Amount of objects that are loaded from the storage. This allows you to load only the first, for example, 10 objects.
Fills an ObjectSet with objects.

Syntax

Visual Basic (Declaration) 
Overloads Public Overridable Function GetObjectSet(Of T)( _
   ByVal query As IQuery, _
   ByVal amount As Integer _
) As ObjectSet(Of T)
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim query As IQuery
Dim amount As Integer
Dim value As ObjectSet(Of T)
 
value = instance.GetObjectSet(Of T)(query, amount)
C# 
public virtual ObjectSet<T> GetObjectSet<T>( 
   IQuery query,
   int amount
)
Managed Extensions for C++ 
public: virtual ObjectSet<T>* GetObjectSet<T>( 
   IQuery* query,
   int amount
) 
C++/CLI 
public:
virtual ObjectSet<T>^ GetObjectSetgeneric<typename T>
( 
   IQuery^ query,
   int amount
) 

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.
amount
Amount of objects that are loaded from the storage. This allows you to load only the first, for example, 10 objects.

Type Parameters

T

Return Value

An instance of an ObjectSet filled with the objects from the storage.

Example

The following example introduces to the use of the GetObjectSet 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. 
  
// Get the ObjectSet for user. 
ObjectSet<User> objectSet = context.GetObjectSet<User> 
    (new ObjectQuery<User>("Name like {0}", "%mith%"), 10); 
  
// Loop through all items and do something. 
foreach(User user in objectSet) 

    // Do something. 

    

Remarks

Returns a filled ObjectSet. An ObjectSet is as a in memory cache for objects.

Requirements

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

See Also