LoadCollection

Use LoadCollection to perform queries. LoadCollection requests are constructed using the LoadCollectionRequestData IDO protocol class.

Properties

These properties are available on the LoadCollectionRequestData class:

Property Data Type Description
IDOName System.String Identifies the IDO used to execute the request.
ReadMode Mongoose.IDO.Protocol. ReadMode Specifies the collection read mode, which controls the isolation level used when executing queries

Options are:

  • ReadCommitted
  • ReadUncommitted
  • Default

This property does not apply to custom load methods.

See the Infor Mongoose Online Help for the list of process defaults.

PropertyList Mongoose.IDO.Protocol. PropertyList Specifies a subset of properties published by the IDO to be included in the response
Filter System.String Specifies a filter or WHERE clause to be used for the query

Default: Empty

RecordCap System.Int32 Specifies the maximum number of items to return in the response

If set to 0, all items are returned. If set to -1, the default cap of 200 items is used.

Default: -1

OrderBy System.String Specifies a list of property names used to override the default sort order

Default: Empty

Only bound properties can be included in OrderBy.

Distinct System.Boolean If set to True, the request returns a set of items containing only the unique combinations of properties named in the PropertyList property

Default: False

CustomLoadMethod Mongoose.IDO.Protocol. CustomLoadMethod Allows the caller to specify a method to perform the query in place of the standard query built by the IDO runtime
PostQueryCommand System.String Allows the caller to specify a method to be executed for each item returned by the query

The method must be a member of the IDO specified by the IDOName property.

Default: Empty

LinkBy Mongoose.IDO.Protocol. PropertyPair array Applies to inner nested LoadCollection requests only and specifies the relationship between a parent and child IDO in terms of property pairs

Use the SetLinkBy method to set this property.

Default: Empty

NestedRequests System.Collections. ICollection Specifies a collection of additional LoadCollectionRequestData instances used to load child collections.
LoadCap System.Int32 Specifies the maximum number of nested LoadCollection requests to process, for example, if this property is set to 1, and 200 items are returned by the parent LoadCollection request, only the first parent item in the response contains nested child items.

LoadCollection example 1

To execute a LoadCollection request, first construct an instance of the LoadCollectionRequestData class, and pass it to the LoadCollection method on the IIDOCommands interface.

LoadCollectionRequestData request = new LoadCollectionRequestData(); 
LoadCollectionResponseData response; 

request.IDOName = "SLItems"; 
request.PropertyList.SetProperties( "Item, Description, QtyOnHand" );
request.Filter = "Item LIKE N'AB%'"; 
request.OrderBy = "QtyOnHand"; 
request.RecordCap = 0; 
response = this.Context.Commands.LoadCollection( request ); 

LoadCollection example 2

In many cases, it is more convenient to call the overloaded version of the LoadCollection method that accepts parameters for the required and most common LoadCollectionRequestData properties.

LoadCollectionResponseData response = LoadCollectionResponseData; 

// This is equivalent to example 1. 
response = this.Context.Commands.LoadCollection( 
   "SLItems", 
   "Item, Description, QtyOnHand", 
   "Item LIKE N'AB%'", 
   "QtyOnHand", 
   0); 

LoadCollection example 3: accessing item properties

The LoadCollection methods return an instance of the LoadCollectionResponseData class, which is populated with the same values that were sent in the request plus the results from the query. These results are accessed through the Items property, which is a collection of IDOItem instances. Properties can be accessed through the IDOItem instances or directly using the indexer on the LoadCollectionResponseData class.

int x = response.PropertyList.IndexOf("QtyOnHand"); 
int qty = 0; 
foreach (IDOItem item in response.Items) 
{ 
   qty += item.PropertyValues[x].GetValue<int>(); 
} 

qty = 0;
for (int row = 0; row < response.Items.Count; row++) 
{ 
   qty += response[row, "QtyOnHand"].GetValue<int>(); 
}