Class Resource
Represents an abstract resource type in the Azure Cosmos DB service. All Azure Cosmos DB resources, such as Database, DocumentCollection, and Document extend this abstract type.
public abstract class Resource : JsonSerializable
- Inheritance
-
Resource
- Derived
- Inherited Members
- Extension Methods
Constructors
Resource()
Initializes a new instance of the Resource class for the Azure Cosmos DB service.
protected Resource()
Resource(Resource)
Copy constructor for a Resource used in the Azure Cosmos DB service.
protected Resource(Resource resource)
Parameters
resource
Resource
Properties
AltLink
Gets the alt-link associated with the resource from the Azure Cosmos DB service.
public string AltLink { get; set; }
Property Value
- string
The alt-link associated with the resource.
ETag
Gets the entity tag associated with the resource from the Azure Cosmos DB service.
public string ETag { get; }
Property Value
- string
The entity tag associated with the resource.
Remarks
ETags are used for concurrency checking when updating resources.
Id
Gets or sets the Id of the resource in the Azure Cosmos DB service.
public virtual string Id { get; set; }
Property Value
- string
The Id associated with the resource.
Remarks
Every resource within an Azure Cosmos DB database account needs to have a unique identifier. Unlike ResourceId, which is set internally, this Id is settable by the user and is not immutable.
When working with document resources, they too have this settable Id property. If an Id is not supplied by the user the SDK will automatically generate a new GUID and assign its value to this property before persisting the document in the database. You can override this auto Id generation by setting the disableAutomaticIdGeneration parameter on the DocumentClient instance to true. This will prevent the SDK from generating new Ids.
The following characters are restricted and cannot be used in the Id property: '/', '\\', '?', '#'
ResourceId
Gets or sets the Resource Id associated with the resource in the Azure Cosmos DB service.
public virtual string ResourceId { get; set; }
Property Value
- string
The Resource Id associated with the resource.
Remarks
A Resource Id is the unique, immutable, identifier assigned to each Azure Cosmos DB resource whether that is a database, a collection or a document. These resource ids are used when building up SelfLinks, a static addressable Uri for each resource within a database account.
SelfLink
Gets the self-link associated with the resource from the Azure Cosmos DB service.
public string SelfLink { get; }
Property Value
- string
The self-link associated with the resource.
Remarks
A self-link is a static addressable Uri for each resource within a database account and follows the Azure Cosmos DB resource model. E.g. a self-link for a document could be dbs/db_resourceid/colls/coll_resourceid/documents/doc_resourceid
Timestamp
Gets the last modified timestamp associated with the resource from the Azure Cosmos DB service.
public virtual DateTime Timestamp { get; }
Property Value
- DateTime
The last modified timestamp associated with the resource.
Methods
GetPropertyValue<T>(string)
Gets property value associated with the specified property name from the Azure Cosmos DB service.
public T GetPropertyValue<T>(string propertyName)
Parameters
propertyName
stringThe name of the property.
Returns
- T
The property value.
Type Parameters
T
The type of the property.
SetPropertyValue(string, object)
Sets property value associated with the specified property name in the Azure Cosmos DB service.
public void SetPropertyValue(string propertyName, object propertyValue)
Parameters
ToByteArray()
Serialize to a byte array via SaveTo for the Azure Cosmos DB service.
public byte[] ToByteArray()
Returns
- byte[]