Class ApiServiceEF<TLoggerCategory, TResources, TDbContext>
Base class for all services implementing EntityFramework data access.
Inheritance
Inherited Members
Namespace: Celerik.NetCore.Services
Assembly: cs.temp.dll.dll
Syntax
public abstract class ApiServiceEF<TLoggerCategory, TResources, TDbContext> : ApiService<TLoggerCategory, TResources> where TDbContext : DbContext
Type Parameters
| Name | Description |
|---|---|
| TLoggerCategory | The type who's name is used for the logger category name. |
| TResources | The type used to localize string resources. |
| TDbContext | The type of DbContext. |
Constructors
ApiServiceEF(ApiServiceArgs<TLoggerCategory>)
Initializes a new instance of the class.
Declaration
public ApiServiceEF(ApiServiceArgs<TLoggerCategory> args)
Parameters
| Type | Name | Description |
|---|---|---|
| ApiServiceArgs<TLoggerCategory> | args | Encapsulates the properties to initialize a new ApiService<TLoggerCategory>. |
ApiServiceEF(ApiServiceArgsEF<TLoggerCategory, TDbContext>)
Initializes a new instance of the class.
Declaration
public ApiServiceEF(ApiServiceArgsEF<TLoggerCategory, TDbContext> args)
Parameters
| Type | Name | Description |
|---|---|---|
| ApiServiceArgsEF<TLoggerCategory, TDbContext> | args | Encapsulates the properties to initialize a new ApiServiceEF<TLoggerCategory, TDbContext>. |
Properties
DbContext
Reference to the current DbContext instance.
Declaration
protected TDbContext DbContext { get; }
Property Value
| Type | Description |
|---|---|
| TDbContext |
Methods
DetachEntities(IEnumerable<Object>)
Detaches all tracked entities from the DbContext.
Declaration
protected void DetachEntities(IEnumerable<object> excludedEntities = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Object> | excludedEntities | List of entities to be excluded in the detaching proccess. |
SaveAsync(ApiChangeAction, Object, Boolean)
Performs an Add/Insert/Delete of an entity into the DbContext.
Declaration
protected virtual Task SaveAsync(ApiChangeAction operation, object entity, bool commit = true)
Parameters
| Type | Name | Description |
|---|---|---|
| ApiChangeAction | operation | The type of operation to perform on the DbContext. |
| System.Object | entity | The entity to Add/Insert/Delete. |
| System.Boolean | commit | Indicates whether changes should be commited immediately. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | The task object representing the asynchronous operation. |
SetConnectionString(String)
Sets the current ConnectionString.
Declaration
protected void SetConnectionString(string connectionString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | connectionString | String used to open the connection. |