Session: How to Defer Operations
Operations can be deferred till SaveChanges
is called by using Defer
method in Advanced
session operations. There are six types of commands that can be deferred:
- PutCommandData
- DeleteCommandData
- DeletePrefixedCommandData
- PatchCommandData
- PutAttachmentCommandData
- DeleteAttachmentCommandData
Syntax
void Defer(ICommandData command, params ICommandData[] commands);
void Defer(ICommandData[] commands);
Parameters | ||
---|---|---|
ICommandData |
Command to be executed. | |
ICommandData[] |
Array of commands implementing ICommandData interface. |
Example
session
.Advanced
.Defer(
new PutCommandData("products/999-A", null, new DynamicJsonValue
{
["Name"] = "My Product",
["Supplier"] = "suppliers/999-A",
["@metadata"] = new DynamicJsonValue
{
["@collection"] = "Users"
}
}),
new PutCommandData("suppliers/999-A", null, new DynamicJsonValue
{
["Name"] = "My Product",
["Supplier"] = "suppliers/999-A",
["@metadata"] = new DynamicJsonValue
{
["@collection"] = "Suppliers"
}
}),
new DeleteCommandData("products/1-A", null)
);