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




list
An instance of a class that implements the IList interface.
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 instance of a class that implements the IList interface with objects.

Syntax

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

Parameters

list
An instance of a class that implements the IList interface.
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

The instance of a class that implements the IList interface.

Exceptions

ExceptionDescription
ArgumentNullExceptionList is null.

Example

The following example introduces to the use of the GetObjectList 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. 
IList<User%gt; userList = null; 
userList = context.GetObjectReader<User>(new List<User>(),  
    new ObjectQuery<User>("Name like {0} SortBy Name Asc", "%mith%"), 10); 
  
// Loop through all items and do something. 
foreach(User user in userList) 

    // Do something. 

    

Remarks

Returns a filled list of objects. All kind of lists that implement the IList interface are allowed.

Requirements

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

See Also