Class DatabaseAccess
Provides the means to access a database table or view. This class contains all the standard CRUD methods to work with a table or view.
Namespace: Paradigm.ORM.Data.DatabaseAccess
Assembly: Paradigm.ORM.Data.dll
Syntax
public class DatabaseAccess : object, IDatabaseAccess, IDisposable
Constructors
| Improve this Doc View SourceDatabaseAccess(IServiceProvider, IDatabaseConnector, ITableTypeDescriptor)
Initializes a new instance of the DatabaseAccess class.
Declaration
public DatabaseAccess(IServiceProvider serviceProvider, IDatabaseConnector connector, ITableTypeDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | The service provider. |
IDatabaseConnector | connector | The database connector. |
ITableTypeDescriptor | descriptor | The table type descriptor. |
DatabaseAccess(IServiceProvider, IDatabaseConnector, Type)
Initializes a new instance of the DatabaseAccess class.
Declaration
public DatabaseAccess(IServiceProvider serviceProvider, IDatabaseConnector connector, Type type)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | A reference to the scoped service provider. |
IDatabaseConnector | connector | A reference to the scoped database connector. |
Type | type | A type containing mapping information, or referencing typing information. |
DatabaseAccess(IServiceProvider, Type)
Initializes a new instance of the DatabaseAccess class.
Declaration
public DatabaseAccess(IServiceProvider serviceProvider, Type type)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | A reference to the scoped service provider. |
Type | type | A type containing mapping information, or referencing typing information. |
DatabaseAccess(IDatabaseConnector, ITableTypeDescriptor)
Initializes a new instance of the DatabaseAccess class.
Declaration
public DatabaseAccess(IDatabaseConnector connector, ITableTypeDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseConnector | connector | A reference to the scoped database connector. |
ITableTypeDescriptor | descriptor | The table type descriptor. |
DatabaseAccess(IDatabaseConnector, Type)
Initializes a new instance of the DatabaseAccess class.
Declaration
public DatabaseAccess(IDatabaseConnector connector, Type type)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseConnector | connector | A reference to the scoped database connector. |
Type | type | A type containing mapping information, or referencing typing information. |
Properties
| Improve this Doc View SourceBatchManager
Gets the batch manager.
Declaration
protected IBatchManager BatchManager { get; }
Property Value
Type | Description |
---|---|
IBatchManager |
CommandBuilderManager
Gets the command builder manager.
Declaration
protected ICommandBuilderManager CommandBuilderManager { get; }
Property Value
Type | Description |
---|---|
ICommandBuilderManager |
Connector
Gets the database connector.
Declaration
protected IDatabaseConnector Connector { get; }
Property Value
Type | Description |
---|---|
IDatabaseConnector |
Descriptor
Gets the table type descriptor.
Declaration
protected ITableTypeDescriptor Descriptor { get; }
Property Value
Type | Description |
---|---|
ITableTypeDescriptor |
Mapper
Gets or sets the mapper.
Declaration
protected IDatabaseReaderMapper Mapper { get; set; }
Property Value
Type | Description |
---|---|
IDatabaseReaderMapper |
NavigationDatabaseAccesses
Gets the list of navigation database access.
Declaration
protected List<INavigationDatabaseAccess> NavigationDatabaseAccesses { get; }
Property Value
Type | Description |
---|---|
List<INavigationDatabaseAccess> |
ServiceProvider
Gets the service provider.
Declaration
protected IServiceProvider ServiceProvider { get; }
Property Value
Type | Description |
---|---|
IServiceProvider |
Methods
| Improve this Doc View SourceAfterInitialize()
Executes logic after the instance has been initialized.
Declaration
protected virtual void AfterInitialize()
BeforeInitialize()
Executes logic previous to initialize the instance.
Declaration
protected virtual void BeforeInitialize()
Delete(IEnumerable<Object>)
Deletes a list of objects from the table or view.
Declaration
public virtual void Delete(IEnumerable<object> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Object> | entities | List of entities to delete. |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
Delete(Object)
Deletes an object from the table or view.
Declaration
public virtual void Delete(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | Object to delete. |
Remarks
If there are more than one element to delete, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Delete(System.Collections.Generic.IEnumerable{System.Object}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
DeleteAsync(IEnumerable<Object>)
Deletes a list of objects from the table or view.
Declaration
public virtual Task DeleteAsync(IEnumerable<object> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Object> | entities | List of entities to delete. |
Returns
Type | Description |
---|---|
Task |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
DeleteAsync(Object)
Deletes an object from the table or view.
Declaration
public virtual Task DeleteAsync(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | Object to delete. |
Returns
Type | Description |
---|---|
Task |
Remarks
If there are more than one element to delete, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Delete(System.Collections.Generic.IEnumerable{System.Object}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
GetStoredProcedure<TProcedure>()
Gets the stored procedure from the service provider.
Declaration
protected TProcedure GetStoredProcedure<TProcedure>()where TProcedure : class, IRoutine
Returns
Type | Description |
---|---|
TProcedure | A instance of the stored procedure. |
Type Parameters
Name | Description |
---|---|
TProcedure | The type of the procedure. |
Remarks
The stored procedure must be registered or this method will fail.
Insert(IEnumerable<Object>)
Inserts a list of objects into the table or view.
Declaration
public virtual void Insert(IEnumerable<object> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Object> | entities | List of entities to insert. |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
Insert(Object)
Inserts an object into the table or view.
Declaration
public virtual void Insert(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | Object to insert. |
Remarks
If there are more than one element to insert, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Insert(System.Collections.Generic.IEnumerable{System.Object}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
InsertAsync(IEnumerable<Object>)
Inserts a list of objects into the table or view.
Declaration
public virtual Task InsertAsync(IEnumerable<object> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Object> | entities | List of entities to insert. |
Returns
Type | Description |
---|---|
Task |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
InsertAsync(Object)
Inserts an object into the table or view.
Declaration
public virtual Task InsertAsync(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | Object to insert. |
Returns
Type | Description |
---|---|
Task |
Remarks
If there are more than one element to insert, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Insert(System.Collections.Generic.IEnumerable{System.Object}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
Select()
Selects a list of all the elements in a table or view.
Declaration
public virtual List<object> Select()
Returns
Type | Description |
---|---|
List<System.Object> | A list of objects that belong to the table or view. |
Remarks
To select filtering results, use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Select(System.String).
Select(String, Object[])
Selects a list of elements in a table or view.
Declaration
public virtual List<object> Select(string whereClause, params object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | whereClause | A where filter clause. Do not add the "WHERE" keyword to it. If you need to pass parameters, pass using @1, @2, @3. |
System.Object[] | parameters | A list of parameter values. |
Returns
Type | Description |
---|---|
List<System.Object> | A list of objects that belong to the table or view. |
SelectAsync()
Selects a list of all the elements in a table or view.
Declaration
public virtual Task<List<object>> SelectAsync()
Returns
Type | Description |
---|---|
Task<List<System.Object>> | A list of objects that belong to the table or view. |
Remarks
To select filtering results, use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Select(System.String).
SelectAsync(String, Object[])
Selects a list of elements in a table or view.
Declaration
public virtual Task<List<object>> SelectAsync(string whereClause, params object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | whereClause | A where filter clause. Do not add the "WHERE" keyword to it. If you need to pass parameters, pass using @1, @2, @3. |
System.Object[] | parameters | A list of parameter values. |
Returns
Type | Description |
---|---|
Task<List<System.Object>> | A list of objects that belong to the table or view. |
SelectOne(Object[])
Selects one element from the database.
Declaration
public virtual object SelectOne(params object[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | ids | Array of id values. |
Returns
Type | Description |
---|---|
System.Object | Element with the same id values as the values provider; otherwise null. |
SelectOneAsync(Object[])
Selects one element from the database.
Declaration
public virtual Task<object> SelectOneAsync(params object[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | ids | Array of id values. |
Returns
Type | Description |
---|---|
Task<System.Object> | Element with the same id values as the values provider; otherwise null. |
Update(IEnumerable<Object>)
Updates a list of objects stored in the table or view.
Declaration
public virtual void Update(IEnumerable<object> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Object> | entities | List of entities to update. |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
Update(Object)
Updates an object already stored in the table or view.
Declaration
public virtual void Update(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | Object to insert. |
Remarks
If there are more than one element to update, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Update(System.Collections.Generic.IEnumerable{System.Object}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
UpdateAsync(IEnumerable<Object>)
Updates a list of objects stored in the table or view.
Declaration
public virtual Task UpdateAsync(IEnumerable<object> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Object> | entities | List of entities to update. |
Returns
Type | Description |
---|---|
Task |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
UpdateAsync(Object)
Updates an object already stored in the table or view.
Declaration
public virtual Task UpdateAsync(object entity)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entity | Object to insert. |
Returns
Type | Description |
---|---|
Task |
Remarks
If there are more than one element to update, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.IDatabaseAccess.Update(System.Collections.Generic.IEnumerable{System.Object}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.