IDataApiEnumerate Method (DataEnumerationQuery, CancellationToken)
|
Query and loop through an extensive collection without writing a lot of code for data paging,
Which is also inefficient when dealing with 100k+ records.
Namespace:
Casewhere.Runtime.DSL.Api
Assembly:
Casewhere.Runtime (in Casewhere.Runtime.dll) Version: 2.8.1.0
Syntax IEnumerable<DynamicDataObject> Enumerate(
DataEnumerationQuery queryBuilder,
CancellationToken token = default
)
Parameters
- queryBuilder
- Type: Casewhere.Runtime.DSL.ApiDataEnumerationQuery
An instance of the DataEnumerationQuery type.
The param contains Data Class Name, Batch Size, Filter, ProjectedFields, SortedFields.
The Instances of DataEnumerationQuery can't create directly.
It is just create from static method DataEnumerationQuery.For("dataClassName").
- token (Optional)
- Type: System.ThreadingCancellationToken
an instance of CancellationToken. If it isn't passed, the default value will be assigned.
Return Value
Type:
IEnumerableDynamicDataObject
The method will returns DynamicDataObject list
Examples var dataApi = ctx.Use<IDataApi>();
var filter = FilterBuilder.Create().Eq("Active", true).Build();
var query = DataEnumerationQuery.For("Employee").FilterBy(filter);
var counter = 0;
foreach (var employee in dataApi.Enumerate(query))
{
var fullName = employee["FirstName"] + " " + employee["LastName"];
dataApi.Update(employee["Id"], new { FullName = fullName });
counter++;
if (counter % 100 == 0)
{
ctx.CommitChanges();
}
}
See Also