LinqRepositoryBase - Aghyad-Khlefawi/Coddee GitHub Wiki
LinqRepositoryBase
A base implementation for a ILinqRepository repository that extends RepositoryBase.
Type parameters
| Name |
Description |
| TDataContext |
The LinqToSQL DataContext type |
Methods
| Name |
Description |
| Initialize(LinqDBManager,IRepositoryManager,IObjectMapper,Type) |
Does the required initialization for the repository |
| Execute(Action[TDataContext]) |
Execute an action on the database context without returning a value |
| Execute(Func[TDataContext,TResult]) |
Execute a function on the database context and then return a value |
| TransactionalExecute(Action[TDataContext,DbTransaction]) |
Execute an action on the database context without returning a value. The action will be wrapped with a transaction. The caller is reasonable for calling transaction.Commit. |
| TransactionalExecute(Action[TDataContext,DbTransaction,TResult]) |
Execute an action on the database contextand then return a value. The action will be wrapped with a transaction. The caller is reasonable for calling transaction.Commit. |
| GetServerUTCDate(DataContext) |
Returns the UTC time form the connected SQL Server |
LinqRepositoryBase
A base implementation for a ILinqRepository that extends LinqRepositoryBase[TDataContext] and adds the functionality to execute queries on a specific table.
Type parameters
| Name |
Description |
| TDataContext |
The LinqToSQL DataContext type |
| TTable |
The LinqToSQL DataContext Table type |
Methods
| Name |
Description |
| Execute(Action[TDataContext, Table[TTable]]) |
Execute an action on the targeted SQL table without returning a value |
| Execute(Func[TDataContextt, Table[TTable],TResult]) |
Execute a function on the targeted SQL table and then return a value |
| TransactionalExecute(Action[TDataContext, Table[TTable],DbTransaction]) |
Execute an action on the targeted SQL table without returning a value. The action will be wrapped with a transaction. The caller is reasonable for calling transaction.Commit. |
| TransactionalExecute(Action[TDataContext, Table[TTable],DbTransaction,TResult]) |
Execute an action on the targeted SQL table and then return a value. The action will be wrapped with a transaction. The caller is reasonable for calling transaction.Commit. |
| GetItemByPrimaryKey(DataContext,object) |
Retrieve an item from SQL server using the table primary key |
ReadOnlyLinqRepositoryBase
A base implementation for a ILinqRepository that extends LinqRepositoryBase[TDataContext] and adds the functionality of the IReadOnlyRepository.
Type parameters
| Name |
Description |
| TDataContext |
The LinqToSQL DataContext type |
| TTable |
The LinqToSQL DataContext Table type |
| TModel |
The business entity model type |
| TKey |
The business entity model primary key type |
Methods
| Name |
Description |
| GetItemFromDB() |
Return all the items from the table |
| TableToModelMapping(List[TTable]) |
Calls the MapItemToModel function to convert an item to the model type |
| MapItemToModel(List[TTable]) |
Maps the collection from the table type to the model type. The default behavior is using the Object mapper but can be overridden to alter the behavior |
CRUDLinqRepositoryBase
A base implementation for a ILinqRepository that extends LinqRepositoryBase[TDataContext] and adds the functionality of the ICRUDRepository.
Type parameters
| Name |
Description |
| TDataContext |
The LinqToSQL DataContext type |
| TTable |
The LinqToSQL DataContext Table type |
| TModel |
The business entity model type |
| TKey |
The business entity model primary key type |
Examples
LinqRepository examples