This is the base clase for DataService classes that implements IDataServices.
Default constructor
protected Void DataServices()
Get the alias of the database table.
public String Alias { get; set; }
Get or set the engine service command builder.
public IDbCmdBuilder CommandBuilder { get; set; }
Get or set the DataAccess interface object.
public IDbAccess DataAccessAPI { get; set; }
Get or set the data update logger object.
public IDataModelAuditor DataModelAuditor { get; set; }
Get or set the SQL builder object.
public IDataModelCmdBuilder DataModelCmdBuilder { get; set; }
Get a list that contains the definition of table fields.
public IDictionary<String, Field> Fields { get; set; }
Get or set the schema or owner of database objects.
public String Schema { get; set; }
Get or set the name of the sequence to use.
public String SequenceName { get; set; }
Converts string to object of a specified DbType.
public IStringToDbTypeConverter StringToDbTypeConverter { get; set; }
Get the 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 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 data source.
public Int32 Delete(model, timestampKind, expectedTimestamp)
Amount of records affected.
Name | Type | Summary |
---|---|---|
model | IDataModel | The object to delete. |
timestampKind | TimestampKind | Kind of timestamp to apply on the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when the model is null. |
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 data source.
public Task<Int32> DeleteAsync(model, timestampKind, expectedTimestamp)
Name | Type | Summary |
---|---|---|
model | IDataModel | The object to delete. |
timestampKind | TimestampKind | Kind of timestamp to apply on the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when the model is null. |
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 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. |
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 object with the primary key data. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
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 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. |
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 object with the primary key data. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when model is null. |
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 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. |
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. |
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. |
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. |
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.
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. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have an Identity column. |
Builds a SelectStatement that retrives a record looking by primary 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. |
DataServiceOperationNotSupportedException | Thrown when the repository does not have a primary key column. |
Insert a record into the underlaying data source
public Int32 Insert(model)
Amount of records affected
Name | Type | Summary |
---|---|---|
model | IDataModel | The object to insert |
Type | Summary |
---|---|
ArgumentNullException | Thrown when the model is null. |
AuditingException | Thrown when an auditing process fails or cannot be completed successfully. |
Insert a record into the underlaying data source
public Task<Int32> InsertAsync(model)
Name | Type | Summary |
---|---|---|
model | IDataModel | The object to insert |
Type | Summary |
---|---|
ArgumentNullException | Thrown when the model is null. |
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 in the underlaying data source
public Int32 Update(model, timestampKind, expectedTimestamp)
Amount of records affected
Name | Type | Summary |
---|---|---|
model | IDataModel | The object to update |
timestampKind | TimestampKind | Kind of timestamp to apply on the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when the model is null. |
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 in the underlaying data source
public Task<Int32> UpdateAsync(model, timestampKind, expectedTimestamp)
Amount of records affected
Name | Type | Summary |
---|---|---|
model | IDataModel | The object to update |
timestampKind | TimestampKind | Kind of timestamp to apply on the WHERE clause. |
expectedTimestamp | DateTime | Timestamp that is expected to be on the database. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when the model is null. |
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