Implements IDataServices fro multi-tenant environments.
Default constructor
protected Void MultitenantDataServices()
Alias of the table.
public String Alias { get; set; }
Database engine command builder.
public IDbCmdBuilder CommandBuilder { get; set; }
Gets or set the service for modification auditing.
public IDataModelAuditor DataModelAuditor { get; set; }
Database engine command builder for data model objects.
public IDataModelCmdBuilder DataModelCmdBuilder { get; set; }
A collection of fields that defines the table columns.
public IDictionary<String, Field> Fields { get; set; }
Schema to which the table belongs to.
public String Schema { get; set; }
Name of the sequence.
public String SequenceName { get; set; }
Converts string to object of a specified DbType.
public IStringToDbTypeConverter StringToDbTypeConverter { get; set; }
Database table name.
public String Table { get; set; }
Appends to the where clause all set terms.
public Void AppendFilterTerms(statement, terms, match)
Name | Type | Summary |
---|---|---|
statement | Statement | Statement to add terms. |
terms | List<Term> | A collections of terms. |
match | MatchKind | How to match the terms. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when statement is null. |
ArgumentNullException | Thrown when terms is null. |
InvalidTermColumnNameException | Thrown when a term.Column name does not exists within the fields collection. |
Appends to statement a predicate that equals field to the specified partitionKeyValue.
protected Void AppendPartitionKeyPredicate(statement, field, partitionKeyValue)
The predicate is appended only if it does not exists.
Name | Type | Summary |
---|---|---|
statement | Statement | The Statement to append the predicate to. |
field | Field | A Field to filter by. |
partitionKeyValue | Object | The actual value of the partition key. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when statement is null. |
ArgumentNullException | Thrown when field is null. |
MissingPartitionKeyException | Thrown when partitionKeyValue is null. |
Appends to statement a predicate that equals the partition key field to the partition key property of the model.
protected Void AppendPartitionKeyPredicate(statement, model)
Name | Type | Summary |
---|---|---|
statement | Statement | The Statement to append the predicate to. |
model | IDataModel | An IDataModel. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when statement is null. -or- When model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has it's the partition key property set. |
InvalidOperationException | Thrown when the field that maps to the partition key property cannot be found. |
Appends to the where clause all set static terms.
public Void AppendStaticTerms(statement, terms)
Name | Type | Summary |
---|---|---|
statement | Statement | Statement to add terms. |
terms | List<StaticTerm> | A collections of terms. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when statement is null. |
ArgumentNullException | Thrown when terms is null. |
InvalidTermColumnNameException | Thrown when a term.Column name does not exists within the fields collection. |
Builds a list of domain model objects of dataModelType from the specified reader.
protected IEnumerable<IDataModel> BuildModelList(dataModelType, reader)
A list of domain model objects.
Name | Type | Summary |
---|---|---|
dataModelType | Type | Type of the domain model object to retrieve. |
reader | IDataReader | The data reader containing the database data. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when dataModelType is null. |
ArgumentNullException | Thrown when reader is null. |
Builds a list of domain model objects of dataModelType from the specified reader.
protected IEnumerable<IDataModel> BuildModelList(dataModelType, reader, parent)
A list of domain model objects.
Name | Type | Summary |
---|---|---|
dataModelType | Type | Type of the domain model object to retrieve. |
reader | IDataReader | The data reader containing the database data. |
parent | IDataModel | Parent object of the model being constructed. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when dataModelType is null. |
ArgumentNullException | Thrown when reader is null. |
Builds a list of domain model objects of
protected IEnumerable BuildModelList<T>(statement)
A list of domain model objects.
Name | Type | Summary |
---|---|---|
statement | SelectStatement | The SelectStatement to excecute. |
Type | Summary |
---|---|
ArgumentNullException | Thrown where statement is null. |
Builds a list of domain model objects of
protected IEnumerable BuildModelList<T>(statement, parent)
A list of domain model objects.
Name | Type | Summary |
---|---|---|
statement | SelectStatement | The SelectStatement to excecute. |
parent | IDataModel | The parent object of the model being constructed. |
Type | Summary |
---|---|
ArgumentNullException | Thrown where statement is null. |
Builds a list of domain model objects of
protected Task<IEnumerable> BuildModelListAsync<T>(statement)
A list of domain model objects.
Name | Type | Summary |
---|---|---|
statement | SelectStatement | The SelectStatement to excecute. |
Type | Summary |
---|---|
ArgumentNullException | Thrown where statement is null. |
Builds a list of domain model objects of
protected Task<IEnumerable> BuildModelListAsync<T>(statement, parent)
A list of domain model objects.
Name | Type | Summary |
---|---|---|
statement | SelectStatement | The SelectStatement to excecute. |
parent | IDataModel | The parent object of the model being constructed. |
Type | Summary |
---|---|
ArgumentNullException | Thrown where statement is null. |
Deletes a record from the underlaying repository.
public Int32 Delete(model, timestampKind, expectedTimestamp)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel to be deleted. |
timestampKind | TimestampKind | Kind of timestamp to apply to the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingRequiredPropertyException | Thrown when the object is not correctly initialized. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey. |
ConcurrectActionMissedException | Thrown when no record was affected and a timestamp kind was specified. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
Deletes a record from the underlaying repository.
public Task<Int32> DeleteAsync(model, timestampKind, expectedTimestamp)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel to be deleted. |
timestampKind | TimestampKind | Kind of timestamp to apply to the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingRequiredPropertyException | Thrown when the object is not correctly initialized. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey. |
ConcurrectActionMissedException | Thrown when no record was affected and a timestamp kind was specified. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
Ensures that model is valid for multi-tenant operations.
protected Void EnsureModelConfiguration(model)
Name | Type | Summary |
---|---|---|
model | IDataModel | A, IDataModel to validate. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
Ensures that this object has a valid state.
protected Void EnsureObjectState()
Type | Summary |
---|---|
MissingRequiredPropertyException | Thrown when a required property is not initialized. |
Enumerates an IDataModel of
protected IEnumerable EnumerateModel<T>(reader)
An enumeration of IDataModel of
Name | Type | Summary |
---|---|---|
reader | IDataReader | An IDataReader with the database data. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when reader is null. |
Enumerates an IDataModel of
protected IEnumerable EnumerateModel<T>(reader, parent)
An enumeration of IDataModel of
Name | Type | Summary |
---|---|---|
reader | IDataReader | An IDataReader with the database data. |
parent | IDataModel | Parent object of the model beeing constructed. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when reader is null. |
Gets a domain model object of dataModelType looking for it's primary key.
public IDataModel GetModel(dataModelType, model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
dataModelType | Type | The Type of the domain model object to retrieve. |
model | IDataModel | An IDataModel holding the primary key to look for. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when dataModelType is null. -or- Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when the this data service object was not properly initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a model object of type
public GetModel<T>(model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
model | T | An instance of the model with the primary key to look for. |
Type | Summary |
---|---|
ArgumentNullException | Thown the model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when the this data service object was not properly initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a domain model object of dataModelType looking for it's primary key.
public Task<IDataModel> GetModelAsync(dataModelType, model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
dataModelType | Type | The Type of the domain model object to retrieve. |
model | IDataModel | An IDataModel holding the primary key to look for. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when dataModelType is null. -or- Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when the this data service object was not properly initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a model object of type
public Task GetModelAsync<T>(model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
model | T | An instance of the model with the primary key to look for. |
Type | Summary |
---|---|
ArgumentNullException | Thown the model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when the this data service object was not properly initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a domain model object of dataModelType looking for it's identity property.
public IDataModel GetModelByIdentity(dataModelType, model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
dataModelType | Type | The Type of the domain model object to retrieve. |
model | IDataModel | An IDataModel holding the identity to look for. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when dataModelType is null. -or- Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when the this data service object was not properly initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a model object of type
public GetModelByIdentity<T>(model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
model | T | An instance of the model object with the identity data. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when a required property is not initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a domain model object of dataModelType looking for it's identity property.
public Task<IDataModel> GetModelByIdentityAsync(dataModelType, model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
dataModelType | Type | The Type of the domain model object to retrieve. |
model | IDataModel | An IDataModel holding the identity to look for. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when dataModelType is null. -or- Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when the this data service object was not properly initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Gets a model object of type
public Task GetModelByIdentityAsync<T>(model)
An initialized data model object.
Name | Type | Summary |
---|---|---|
model | T | An instance of the model object with the identity data. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingPartitionKeyPropertyException | Thrown when model does not has a partition key property. |
MissingPartitionKeyException | Thrown when model does not has the partition key property set. |
MissingRequiredPropertyException | Thrown when a required property is not initialized. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Builds a SelectStatement that retrives a record looking by identity and filtering by the partition key.
protected SelectStatement GetRowByIdentityStatement(model)
A SelectStatement to execute.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel that holds the identity. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey property or the property is not an IDataProperty. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have an Identity column. |
Builds a SelectStatement that retrives a record looking by primary key and filtering by the partition key.
protected SelectStatement GetRowByPrimaryKeyStatement(model)
A SelectStatement to execute.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel that holds the primary key. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey property or the property is not an IDataProperty. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Inserts a record into the underlaying repository.
public Int32 Insert(model)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel to be inserted. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingRequiredPropertyException | Thrown when the object is not correctly initialized. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
Inserts a record into the underlaying repository.
public Task<Int32> InsertAsync(model)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel to be inserted. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingRequiredPropertyException | Thrown when the object is not correctly initialized. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
Run a count statement and returns the count.
protected Int32 RunCountStatement(statement)
Name | Type | Summary |
---|---|---|
statement | SelectStatement | The statement to run. |
Type | Summary |
---|---|
ArgumentNullException | Thrown where statement is null. |
Run a count statement and returns the count.
protected Task<Int32> RunCountStatementAsync(statement)
Name | Type | Summary |
---|---|---|
statement | SelectStatement | The statement to run. |
Type | Summary |
---|---|
ArgumentNullException | Thrown where statement is null. |
Calculates the maximum page number and returns the specified page or the maximun page number if page is not valid.
protected Int32 SanitizePageNumber(page, pageLength, totalItems)
A sanitized page number.
Name | Type | Summary |
---|---|---|
page | Int32 | Attempted page number. |
pageLength | Int32 | Page length. |
totalItems | Int32 | Total items. |
Updates a record on the underlaying repository.
public Int32 Update(model, timestampKind, expectedTimestamp)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel to be updated. |
timestampKind | TimestampKind | Kind of timestamp to apply to the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingRequiredPropertyException | Thrown when the object is not correctly initialized. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey. |
ConcurrectActionMissedException | Thrown when no record was affected and a timestamp kind was specified. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
Updates a record on the underlaying repository.
public Task<Int32> UpdateAsync(model, timestampKind, expectedTimestamp)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | An IDataModel to be updated. |
timestampKind | TimestampKind | Kind of timestamp to apply to the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
MissingRequiredPropertyException | Thrown when the object is not correctly initialized. |
MissingPartitionKeyException | Thrown when model does not have a PartitionKey. |
ConcurrectActionMissedException | Thrown when no record was affected and a timestamp kind was specified. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
In this document