XpoDefault.GetTerminalInSize(Int32, Int32) Method
Returns the optimal packet size (the number of operands in a packet) for a specified number of operands passed to the InOperator.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
size | Int32 | An integer value which specifies the projected number of operands to be passed to the InOperator.Operands collection. |
parametersPerObject | Int32 | An integer value which specifies the number of SQL parameters needed to represent an operand. |
Returns
Type | Description |
---|---|
Int32 | An integer value which specifies the optimal packet size, in operands. |
Remarks
If the InOperator.Operands collection contains a number of operands, executing the resulting query generated for the collection may significantly reduce server performance, or even bring it down. To improve performance, we recommend that you split InOperator operands in packets, and pass packets to the InOperator.Operands collection, one at a time. The GetTerminalInSize method determines the optimal packet size (the number of operands in a packet) for a specified number of operands you are going to pass to the InOperator.Operands collection.
Example
The following code snippet shows how to use the GetTerminalInSize method to retrieve a number of persistent objects (folders) by passing their names to the InOperator.
void UpdateFolders(List<string> names) {
int position = 0;
while (position < names.Count) {
int restCount = names.Count - position;
int packetSize = XpoDefault.GetTerminalInSize(restCount);
using (UnitOfWork uow = new UnitOfWork()) {
XPCollection<Folder> folders = new XPCollection<Folder>(uow,
new InOperator("Name", names.GetRange(position, packetSize)));
position += packetSize;
foreach (Folder folder in folders) {
// Processing folders...
}
}
}
}