Updating Multiple Objects¶
This API updates multiple objects in a data table with a single request. Consider the following example, it demonstrates an API call which updates all objects in the Person
data table where the value of the property age
is greater than 20
. As a result of the request, all updated objects will have the contactType
property set to "personal"
:
Dictionary<string, object> changes = new Dictionary<string, object>();
changes[ "contactType" ] = "personal";
AsyncCallback<int> bulkUpdateCallback = new AsyncCallback<int>(
objectsUpdated =>
{
System.Console.WriteLine( String.Format( "Server has updated {0} objects in the database", objectsUpdated ) );
},
error =>
{
System.Console.WriteLine( "Server returned an error " + error.Message );
} );
Backendless.Data.Of( "Person" ).Update( "age > 20", changes, bulkUpdateCallback );
Blocking Method¶
int Backendless.Data.Of( "TABLE-NAME" ).Update(
String whereClause,
Dictionary<string, object> changes );
public int Backendless.Data.Of<E>().Update(
String whereClause,
Dictionary<string, object> changes );
Non-Blocking API¶
void Backendless.Data.Of( "TABLE-NAME" ).Update(
String whereClause,
Dictionary<string, object> changes,
AsyncCallback<int> responder )
public void Backendless.Data.Of<E>().Update(
String whereClause,
Dictionary<string, object> changes,
AsyncCallback<int> responder )
where:
Argument | Description |
---|---|
TABLE-NAME |
Name of the table where the objects are updated. |
E |
A .NET class of the data objects to save. |
whereClause |
A condition for selecting objects in the data table which will be updated. |
changes |
A dictionary containing the changes which will be applied to all objects in the data table which match the condition expressed via whereClause . |
responder |
a responder object which will receive a callback when the method successfully updates the objects or if an error occurs. Applies to the non-blocking method only. |
Return Value¶
The method returns the number of objects updated in the database.