UploadCategory

public class UploadCategory

Specifies a upload categoy to use for a request.

The following example creates a customer and a related order where both operations use the new customer’s entity ID as the upload category:

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 upload category of the request
// will be the generated entity ID.
let createCustomerOptions = OfflineODataRequestOptions()
createCustomerOptions.uploadCategory = UploadCategory.useGeneratedIDForUploadCategory()
service.createEntity( newCustomer, options: createCustomerOptions )

// This will create the new order related to the new customer and the upload category
// will be the entity ID of the newly created customer.
let createOrderOptions = OfflineODataRequestOptions()
createOrderOptions.uploadCategory = UploadCategory( newCustomer )
service.createRelatedEntity( newOrder, in: newCustomer, property: ordersNavigationProperty, options: createOrderOptions )
  • A static function to specify to use the generated entity ID for a created entity or media entity as the upload category for the request.

    Using the generated entity ID as an upload category is ideal for cases where requests for a new entity need to be grouped into an upload categoty but there is no other pre-defined upload category.

    Using the generated entity ID as an upload category is also ideal for cases where a graph of related entities (for example, a parent-child heirarchy) needs to be grouped into an upload categoty and the entity ID of the to be created root is the ideal choice for the upload category type.

    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 upload category.

    The generated entity ID can not be used as an upload category in upload process

    Declaration

    Swift

    public static func useGeneratedIDForUploadCategory() -> UploadCategory
  • Sets the entity ID of the specified EntityValue as the upload category.

    This is a convenient way to have a graph of entities (for example, a parent-child heirarchy) all be grouped into the same upload category by referencing the root entity as the upload category.

    Declaration

    Swift

    public init(entity: EntityValue)
  • Sets a pre-defined string as the upload category.

    Throws

    OfflineODataError.invalidInput if the value is the empty string or a string that only contains white space. Possible error name could be: OfflineODataErrorName.invalidStringUploadCategory.

    Declaration

    Swift

    public init(stringLiteral: String) throws
  • The type of upload category stored.

    Declaration

    Swift

    public var uploadCategoryType: UploadCategoryType { get }
  • The string literal that was specified as the upload category.

    Declaration

    Swift

    public var stringLiteral: String { get }
  • The referenced EntityValue whose entity ID will be used as the upload category.

    Declaration

    Swift

    public internal(set) var entityValue: EntityValue { get set }