Hello
Im using this code to delete all the records, its posible made the delete without a form? or made the delete by definition
var read = domHelper.DomInstances.ReadAll();
foreach (var item in read)
{
domHelper.DomInstances.Delete(item);
}
Regards
Juan
Hi Juan,
There's a solid documentation page that addresses Processing multiple DomInstances - examples | DataMiner Docs. Feel free to take a look. There's a specific section as well related to deletion.
// Retrieve the DomInstances that need to get deleted. var domInstances = domHelper.DomInstances.Read(filter); // Remove them from the DB. var deleteResult = domHelper.DomInstances.Delete(domInstances);
Kind Regards,
Jarno
Hi Juan,
Here is an example of deleting DOM instances filtered by definition and state. Note that there is a limit of 100, so you can use a batching method to delete them in chunks.
private void DeleteInstancesInBatches(DomHelper domHelper, List<DomInstance> instances, int batchSize)
{
for (int i = 0; i < instances.Count; i += batchSize)
{
int countToRemove = Math.Min(instances.Count - i, batchSize);
domHelper.DomInstances.Delete(
instances
.GetRange(i, countToRemove)
.ToList());
}
}
private void RemoveCancelledTasks()
{
DomHelper domHelper = new DomHelper(_engine.SendSLNetMessages, SlcTasksIds.ModuleId);
var definitionFilter = DomInstanceExposers.DomDefinitionId.Equal(SlcTasksIds.Definitions.Task.Id);
var stateFilter = DomInstanceExposers.StatusId.Equal(SlcTasksIds.Behaviors.TaskFlow.Statuses.Cancelled);
var taskInstances = domHelper.DomInstances
.Read(definitionFilter.AND(stateFilter))
.ToList();
DeleteInstancesInBatches(domHelper, taskInstances, 100);
}
Thanks, i was looking but dint find it.