TransactionID
public class TransactionID
Specifies a transaction ID to use for a request when OfflineODataParameters.enableTransactionBuilder
is true
.
Here is an example of creating a Customer and a related Order and having both operations use the new Customer’s entity ID as the transaction ID so that they both get put in the same transaction by the transaction builder:
let newCustomer = EntityValue( type: customerEntityType )
let newOrder = EntityValue( type: orderEntityType )
// Fill in newCustomer and newOrder properties here...
// This will create the new customer and the transaction ID of the request
// will be the generated entity ID.
let createCustomerOptions = OfflineODataRequestOptions()
createCustomerOptions.transactionID = TransactionID.useGeneratedIDForTransactionID
service.createEntity( newCustomer, options: createCustomerOptions )
// This will create the new order related to the new customer and the transaction ID
// will be the entity ID of the newly created customer.
let createOrderOptions = OfflineODataRequestOptions()
createOrderOptions.transactionID = TransactionID( newCustomer )
service.createRelatedEntity( newOrder, in: newCustomer, property: ordersNavigationProperty, options: createOrderOptions )
-
A constant to specify to use the generated entity ID for a created entity or media entity as the transaction ID for the request.
Using the generated entity ID as a transaction ID is ideal for cases where requests for a new entity need to be grouped into a transaction but there is no other pre-defined transaction ID.
Using the generated entity ID as a transaction ID is also ideal for cases where a graph of related entities (for example, a parent-child heirarchy) needs to be grouped into a transaction and the entity ID of the to be created root is the ideal choice for the transaction ID.
Note that this can be used in a change set and subsequent requests in the change set can reference the created entity (by EntityValue) to also be grouped in the same transaction.
Declaration
Swift
public static let useGeneratedIDForTransactionID: TransactionID
-
Sets the entity ID of the specified EntityValue as the transaction ID.
This is a convenient way to have a graph of entities (for example, a parent-child heirarchy) all be grouped into the same transaction by referencing the root entity as the transaction ID.
Declaration
Swift
public init(entity: EntityValue)
-
Sets a pre-defined string as the transaction ID.
Throws
OfflineODataError
if the value is the empty string or a string that only contains white space.Declaration
Swift
public init(stringLiteral: String) throws
-
The type of transaction ID stored.
Declaration
Swift
public var transactionIDType: TransactionIDType { get }
-
The string literal that was specified as the transaction ID.
Declaration
Swift
public var stringLiteral: String { get }
-
The referenced EntityValue whose entity ID will be used as the transaction ID.
Declaration
Swift
public var entityValue: EntityValue { get }