Web Services

Delete an Existing Record Using External Web Service

This customization shows how to use a web service to delete data from a web service-based data source. This provides an alternate way to access data than the database stored procedure and inline SQL normally generated by Iron Speed Designer.
Table Name
Select the database table
Primary Key
Select the primary key field in the table
Applies to
SQLAccessClass class
/// Deletes a record from the table.
/// The table to delete from.
/// Nothing, or a filter that restricts which records get deleted.
/// Nothing, or the specific sort order in which the records get deleted.
/// The zero-based index of the first record to delete.
/// The exact number of records to delete.
/// The total number of matching records (ignoring page boundaries).
public override void DeleteRecords(
    BaseClasses.Data.TableDefinition table, 
    BaseClasses.Data.BaseFilter filter, 
    BaseClasses.Data.OrderBy sortOrder, 
    int startIndex, 
    int count, 
    ref int totalCount) 

        // If we are deleting using a primary key, then
        // just call the web service that deletes one record.    
        if ((filter != null) && (filter is BaseClasses.Data.PrimaryKeyValueFilter)) 
            int ${Primary Key} = Get${Primary Key}FromFilter(filter); 

            // Instantiate the object that will communicate with a web service.
            // Replace "MyWebServiceForTableAccess" with the external web service name
            localhost.MyWebServiceForTableAccess webService; 
            webService = new localhost.MyWebServiceForTableAccess(); 
            webService.Credentials = System.Net.CredentialCache.DefaultCredentials; 

            // Call the web service's "DeleteRecord" function.
            webService.Delete${${Table Name}RecordClassName}(${Primary Key}); 
            totalCount = 1; 
        // Else use the normal path to delete records, e.g. using stored procedures, or inline SQL.
        // You can customize this to call your web service instead.
        base.DeleteRecords(table, filter, sortOrder, startIndex, count, ref totalCount); 

Applies to
SQLAccessClass class
/// Given filter, get the ${Primary Key}.
public int Get${Primary Key}FromFilter(BaseClasses.Data.BaseFilter filter) 
    // Define a primary key value filter.
    BaseClasses.Data.PrimaryKeyValueFilter pkFilter; 
    pkFilter = ((BaseClasses.Data.PrimaryKeyValueFilter)(filter)); 

    // Get the primary key.
    BaseClasses.Data.KeyValue myPrimaryKey = pkFilter.Value; 
    ${${Table Name}ClassName} ${Table Name}Acc = ${${Table Name}ClassName}.Instance; 
    int ${Primary Key}; 
    ${Primary Key} = myPrimaryKey.GetColumnValue(${Table Name}Acc.${Primary Key}Column).ToInt32(); 
    return ${Primary Key}; 

Terms of Service Privacy Statement