Creatio development guide
PDF
This documentation is valid for Creatio version 7.16.0. We recommend using the newest version of Creatio documentation.

Deleting data

Glossary Item Box

Examples of using the Delete class to erase data

You can download the package with the configuration web service implementing the cases described below using the following link.

In most cases, the deletion request should contain the Where condition, which specifies which records exactly should be deleted. Otherwise, all records will be deleted.

The example code demonstrates available methods for passing parameters to the query. When developing a project, be aware that parameters originating from the user should never be passed to the Column.Const method, since this can lead to a successful SQL injection attack.

Example 1

Receive the SQL-query text
 
 
public string GetSqlTextExample(string name)
{
    var result = "";
    var delete = new Delete(UserConnection)
        .From("Contact")
        .Where("Name").IsEqual(Column.Parameter(name));
    result = delete.GetSqlText();
    return result;
}

Example 2

Change the contact name to another one
 
 
public string DeleteContacts(string name)
{
    var delete = new Delete(UserConnection)
        .From("Contact")
        .Where("Name").IsEqual(Column.Parameter(name));
    var cnt = delete.Execute();
    return $"Contacts with name {name} were deleted. {cnt} rows affected";
}

See also:

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?