Class TableEntity
- Namespace
- Microsoft.WindowsAzure.Storage.Table
- Assembly
- Microsoft.WindowsAzure.Storage.dll
Represents the base object type for a table entity in the Table service.
public class TableEntity : ITableEntity
- Inheritance
-
TableEntity
- Implements
- Derived
- Inherited Members
Remarks
TableEntity provides a base implementation for the ITableEntity interface that provides ReadEntity(IDictionary<string, EntityProperty>, OperationContext) and WriteEntity(OperationContext) methods that by default serialize and deserialize all properties via reflection. A table entity class may extend this class and override the ReadEntity(IDictionary<string, EntityProperty>, OperationContext) and WriteEntity(OperationContext) methods to provide customized or better performing serialization logic.
Constructors
TableEntity()
Initializes a new instance of the TableEntity class.
public TableEntity()
TableEntity(string, string)
Initializes a new instance of the TableEntity class with the specified partition key and row key.
public TableEntity(string partitionKey, string rowKey)
Parameters
partitionKey
stringA string containing the partition key of the TableEntity to be initialized.
rowKey
stringA string containing the row key of the TableEntity to be initialized.
Properties
DisableCompiledSerializers
Disables the ability to dynamically generate read and write lambdas at runtime. Setting this to false will clear out the static cache shared across all type instances that derive from TableEntity.
public static bool DisableCompiledSerializers { get; set; }
Property Value
DisablePropertyResolverCache
Gets or sets the status of the property resolver cache for the TableEntity.
public static bool DisablePropertyResolverCache { get; set; }
Property Value
Remarks
The property resolver cache caches known entity types and their respective property resolver dictionaries when entities are deserialized and the payload does not include JSON metadata. For most scenarios, disabling the property resolver cache is not recommended due to its effect on performance.
ETag
Gets or sets the entity's ETag. Set this value to '*' in order to force an overwrite to an entity as part of an update operation.
public string ETag { get; set; }
Property Value
- string
A string containing the ETag value for the entity.
PartitionKey
Gets or sets the entity's partition key.
public string PartitionKey { get; set; }
Property Value
- string
A string containing the partition key for the entity.
RowKey
Gets or sets the entity's row key.
public string RowKey { get; set; }
Property Value
- string
A string containing the row key for the entity.
Timestamp
Gets or sets the entity's timestamp.
public DateTimeOffset Timestamp { get; set; }
Property Value
- DateTimeOffset
A DateTimeOffset containing the timestamp of the entity.
Methods
ConvertBack<TResult>(IDictionary<string, EntityProperty>, OperationContext)
Returns a custom entity instance which is recomposed using the specified IDictionary<TKey, TValue> of property names to EntityProperty data typed values.
public static TResult ConvertBack<TResult>(IDictionary<string, EntityProperty> properties, OperationContext operationContext)
Parameters
properties
IDictionary<string, EntityProperty>An IDictionary<TKey, TValue> object that maps string property names to EntityProperty data values to deserialize and store in this table entity instance.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- TResult
Type Parameters
TResult
The type of the recomposed object. This can be a simple object with a flat structure or a complex object with complex properties and multiple levels of object hierarchy.
ConvertBack<TResult>(IDictionary<string, EntityProperty>, EntityPropertyConverterOptions, OperationContext)
Returns a custom entity instance which is recomposed using the specified IDictionary<TKey, TValue> of property names to EntityProperty data typed values.
public static TResult ConvertBack<TResult>(IDictionary<string, EntityProperty> properties, EntityPropertyConverterOptions entityPropertyConverterOptions, OperationContext operationContext)
Parameters
properties
IDictionary<string, EntityProperty>An IDictionary<TKey, TValue> object that maps string property names to EntityProperty data values to deserialize and store in this table entity instance.
entityPropertyConverterOptions
EntityPropertyConverterOptionsA EntityPropertyConverterOptions object that specifies options for the entity property conversion.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- TResult
Type Parameters
TResult
The type of the recomposed object. This can be a simple object with a flat structure or a complex object with complex properties and multiple levels of object hierarchy.
Flatten(object, OperationContext)
Flattens the entity and creates a IDictionary<TKey, TValue> of EntityProperty objects for all properties of the specified entity object.
public static IDictionary<string, EntityProperty> Flatten(object entity, OperationContext operationContext)
Parameters
entity
objectThe entity object to serialize.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- IDictionary<string, EntityProperty>
An IDictionary<TKey, TValue> of EntityProperty objects for all the properties of the specified entity object.
Remarks
The entity type can be a simple object with a flat structure or a complex object with complex properties and multiple levels of object hierarchy. Generic ConvertBack method can recompose the original entity using the return value of this method.
Flatten(object, EntityPropertyConverterOptions, OperationContext)
Flattens the entity and creates a IDictionary<TKey, TValue> of EntityProperty objects for all properties of the specified entity object.
public static IDictionary<string, EntityProperty> Flatten(object entity, EntityPropertyConverterOptions entityPropertyConverterOptions, OperationContext operationContext)
Parameters
entity
objectThe entity object to serialize.
entityPropertyConverterOptions
EntityPropertyConverterOptionsA EntityPropertyConverterOptions object that specifies options for the entity property conversion.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- IDictionary<string, EntityProperty>
An IDictionary<TKey, TValue> of EntityProperty objects for all the properties of the specified entity object.
Remarks
The entity type can be a simple object with a flat structure or a complex object with complex properties and multiple levels of object hierarchy. Generic ConvertBack method can recompose the original entity using the return value of this method.
ReadEntity(IDictionary<string, EntityProperty>, OperationContext)
Deserializes the entity using the specified IDictionary<TKey, TValue> that maps property names to typed EntityProperty values.
public virtual void ReadEntity(IDictionary<string, EntityProperty> properties, OperationContext operationContext)
Parameters
properties
IDictionary<string, EntityProperty>An IDictionary<TKey, TValue> object that maps property names to typed EntityProperty values.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
ReadUserObject(object, IDictionary<string, EntityProperty>, OperationContext)
Deserializes a custom entity instance using the specified IDictionary<TKey, TValue> of property names to EntityProperty data typed values.
public static void ReadUserObject(object entity, IDictionary<string, EntityProperty> properties, OperationContext operationContext)
Parameters
entity
objectThe custom entity instance being deserialized.
properties
IDictionary<string, EntityProperty>An IDictionary<TKey, TValue> object that maps string property names to EntityProperty data values to deserialize and store in this table entity instance.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
WriteEntity(OperationContext)
Serializes the IDictionary<TKey, TValue> of property names mapped to EntityProperty data values from this TableEntity instance.
public virtual IDictionary<string, EntityProperty> WriteEntity(OperationContext operationContext)
Parameters
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- IDictionary<string, EntityProperty>
An IDictionary<TKey, TValue> object that maps string property names to EntityProperty typed values created by serializing this table entity instance.
WriteUserObject(object, OperationContext)
Create a IDictionary<TKey, TValue> of EntityProperty objects for all the properties of the specified entity object.
public static IDictionary<string, EntityProperty> WriteUserObject(object entity, OperationContext operationContext)
Parameters
entity
objectThe entity object to serialize.
operationContext
OperationContextAn OperationContext object that represents the context for the current operation.
Returns
- IDictionary<string, EntityProperty>
An IDictionary<TKey, TValue> of EntityProperty objects for all the properties of the specified entity object.