Class DatabaseAccess<TEntity>
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.
Inherited Members
Namespace: Paradigm.ORM.Data.DatabaseAccess.Generic
Assembly: Paradigm.ORM.Data.dll
Syntax
public class DatabaseAccess<TEntity> : DatabaseAccess, IDatabaseAccess<TEntity>, IDatabaseAccess, IDisposable where TEntity : class
Type Parameters
Name | Description |
---|---|
TEntity | A type containing or referencing the mapping information. |
Constructors
| Improve this Doc View SourceDatabaseAccess(IServiceProvider)
Initializes a new instance of the DatabaseAccess<TEntity> class.
Declaration
public DatabaseAccess(IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | The service provider. |
DatabaseAccess(IServiceProvider, IDatabaseConnector)
Initializes a new instance of the DatabaseAccess<TEntity> class.
Declaration
public DatabaseAccess(IServiceProvider serviceProvider, IDatabaseConnector connector)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | The service provider. |
IDatabaseConnector | connector | The database connector. |
DatabaseAccess(IDatabaseConnector)
Initializes a new instance of the DatabaseAccess<TEntity> class.
Declaration
public DatabaseAccess(IDatabaseConnector connector)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseConnector | connector | The database connector. |
Methods
| Improve this Doc View SourceDelete(TEntity)
Deletes a
Declaration
public virtual void Delete(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Remarks
If there are more than one element to delete, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Delete(System.Collections.Generic.IEnumerable{`0}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
Delete(IEnumerable<TEntity>)
Deletes a list of
Declaration
public virtual void Delete(IEnumerable<TEntity> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | List of |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
DeleteAsync(TEntity)
Deletes a
Declaration
public virtual Task DeleteAsync(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Returns
Type | Description |
---|---|
Task |
Remarks
If there are more than one element to delete, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Delete(System.Collections.Generic.IEnumerable{`0}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
DeleteAsync(IEnumerable<TEntity>)
Deletes a list of
Declaration
public virtual Task DeleteAsync(IEnumerable<TEntity> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | List of |
Returns
Type | Description |
---|---|
Task |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
Insert(TEntity)
Inserts a
Declaration
public virtual void Insert(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Remarks
If there are more than one element to insert, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Insert(System.Collections.Generic.IEnumerable{`0}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
Insert(IEnumerable<TEntity>)
Inserts a list of
Declaration
public virtual void Insert(IEnumerable<TEntity> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | List of |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
InsertAsync(TEntity)
Inserts a
Declaration
public virtual Task InsertAsync(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Returns
Type | Description |
---|---|
Task |
Remarks
If there are more than one element to insert, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Insert(System.Collections.Generic.IEnumerable{`0}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
InsertAsync(IEnumerable<TEntity>)
Inserts a list of
Declaration
public virtual Task InsertAsync(IEnumerable<TEntity> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | List of |
Returns
Type | Description |
---|---|
Task |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
Select()
Selects a list of all the elements in a table or view.
Declaration
public List<TEntity> Select()
Returns
Type | Description |
---|---|
List<TEntity> | A list of |
Remarks
To select filtering results, use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Select(System.String).
Select(String, Object[])
Selects a list of elements in a table or view.
Declaration
public List<TEntity> 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<TEntity> | A list of |
SelectAsync()
Selects a list of all the elements in a table or view.
Declaration
public Task<List<TEntity>> SelectAsync()
Returns
Type | Description |
---|---|
Task<List<TEntity>> | A list of |
Remarks
To select filtering results, use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Select(System.String).
SelectAsync(String, Object[])
Selects a list of elements in a table or view.
Declaration
public Task<List<TEntity>> 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<TEntity>> | A list of |
SelectOne(Object[])
Selects one element from the database.
Declaration
public TEntity SelectOne(params object[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | ids | Array of id values. |
Returns
Type | Description |
---|---|
TEntity |
SelectOneAsync(Object[])
Selects one element from the database.
Declaration
public Task<TEntity> SelectOneAsync(params object[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | ids | Array of id values. |
Returns
Type | Description |
---|---|
Task<TEntity> |
Update(TEntity)
Updates a
Declaration
public virtual void Update(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Remarks
If there are more than one element to update, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Update(System.Collections.Generic.IEnumerable{`0}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
Update(IEnumerable<TEntity>)
Updates a list of
Declaration
public virtual void Update(IEnumerable<TEntity> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | List of |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.
UpdateAsync(TEntity)
Updates a
Declaration
public virtual Task UpdateAsync(TEntity entity)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Returns
Type | Description |
---|---|
Task |
Remarks
If there are more than one element to update, please use the overloaded method Paradigm.ORM.Data.DatabaseAccess.Generic.IDatabaseAccess`1.Update(System.Collections.Generic.IEnumerable{`0}) because is prepared to batch the operation, and preventing unnecessary roundtrips to the database.
UpdateAsync(IEnumerable<TEntity>)
Updates a list of
Declaration
public virtual Task UpdateAsync(IEnumerable<TEntity> entities)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | List of |
Returns
Type | Description |
---|---|
Task |
Remarks
This method utilizes batching to prevent unnecessary roundtrips to the database.