A base implementation of the Code First Data DataContext for Entity Framework
More...
List of all members.
Public Member Functions |
| DataContext (string connectionString, IMappingConfiguration mapping, IContextConfiguration contextConfiguration=null, ILog log=null) |
| Constructs a context
|
IQueryable< T > | AsQueryable< T > () |
| This gives a mockable wrapper around the normal DbSet{T} method that allows for testablity
|
T | Add< T > (T item) |
| Adds the provided instance of T to the data context
|
T | Remove< T > (T item) |
| Removes the provided instance of T from the data context
|
T | Update< T > (T item) |
| Updates the provided instance of T in the data context
|
T | Attach< T > (T item) |
| Attaches the provided instance of T to the data context
|
T | Detach< T > (T item) |
| Detaches the provided instance of T from the data context
|
T | Reload< T > (T item) |
| Reloads the provided instance of T from the database
|
int | Commit () |
| Commits all currently tracked entity changes
|
IEnumerable< T > | ExecuteSqlQuery< T > (string sql, params DbParameter[] dbParams) |
| Executes a SQL command and tries to map the returned datasets into an IEnumerable{T} The results should have the same column names as the Entity Type has properties
|
int | ExecuteSqlCommand (string sql, params DbParameter[] dbParams) |
| Executes a SQL command and returns the standard int return from the query
|
int | ExecuteFunction (string procedureName, params ObjectParameter[] dbParams) |
|
|
Protected Member Functions |
override void | OnModelCreating (DbModelBuilder modelBuilder) |
| This method is called when the model for a derived context has been initialized, but before the model has been locked down and used to initialize the context. The default implementation of this method takes the IMappingConfiguration array passed in on construction and applies them. If no configuration mappings were passed it it does nothing.
|
Properties |
IEventManager | EventManager [get, set] |
| The reference to EventManager that allows for ordered event handling and registration
|
Detailed Description
A base implementation of the Code First Data DataContext for Entity Framework
Constructor & Destructor Documentation
Constructs a context
- Parameters:
-
connectionString | The standard SQL connection string for the Database |
mapping | The Mapping Configuration that will determine how the tables and objects interact |
contextConfiguration | The context specific configuration that will change context level behavior ( Optional ) |
log | The logger being supplied for this context ( Optional ) |
Member Function Documentation
T Highway.Data.DataContext.Add< T > |
( |
T |
item | ) |
|
|
inline |
Adds the provided instance of T to the data context
- Template Parameters:
-
T | The Entity Type being added |
- Parameters:
-
item | The T you want to add |
- Returns:
- The T you added
Implements Highway.Data.Interfaces.IDataContext.
IQueryable<T> Highway.Data.DataContext.AsQueryable< T > |
( |
| ) |
|
|
inline |
This gives a mockable wrapper around the normal DbSet{T} method that allows for testablity
- Template Parameters:
-
T | The Entity being queried |
- Returns:
- IQueryable{T}
Implements Highway.Data.Interfaces.IDataContext.
T Highway.Data.DataContext.Attach< T > |
( |
T |
item | ) |
|
|
inline |
Attaches the provided instance of T to the data context
- Template Parameters:
-
T | The Entity Type being attached |
- Parameters:
-
item | The T you want to attach |
- Returns:
- The T you attached
Implements Highway.Data.Interfaces.IDataContext.
int Highway.Data.DataContext.Commit |
( |
| ) |
|
|
inline |
T Highway.Data.DataContext.Detach< T > |
( |
T |
item | ) |
|
|
inline |
Detaches the provided instance of T from the data context
- Template Parameters:
-
T | The Entity Type being detached |
- Parameters:
-
item | The T you want to detach |
- Returns:
- The T you detached
Implements Highway.Data.Interfaces.IDataContext.
int Highway.Data.DataContext.ExecuteFunction |
( |
string |
procedureName, |
|
|
params ObjectParameter[] |
dbParams |
|
) |
| |
|
inline |
int Highway.Data.DataContext.ExecuteSqlCommand |
( |
string |
sql, |
|
|
params DbParameter[] |
dbParams |
|
) |
| |
|
inline |
Executes a SQL command and returns the standard int return from the query
- Parameters:
-
sql | The Sql Statement |
dbParams | A List of Database Parameters for the Query |
- Returns:
- The rows affected
Implements Highway.Data.Interfaces.IDataContext.
IEnumerable<T> Highway.Data.DataContext.ExecuteSqlQuery< T > |
( |
string |
sql, |
|
|
params DbParameter[] |
dbParams |
|
) |
| |
|
inline |
Executes a SQL command and tries to map the returned datasets into an IEnumerable{T} The results should have the same column names as the Entity Type has properties
- Template Parameters:
-
T | The Entity Type that the return should be mapped to |
- Parameters:
-
sql | The Sql Statement |
dbParams | A List of Database Parameters for the Query |
- Returns:
- An IEnumerable{T} from the query return
Implements Highway.Data.Interfaces.IDataContext.
override void Highway.Data.DataContext.OnModelCreating |
( |
DbModelBuilder |
modelBuilder | ) |
|
|
inlineprotected |
This method is called when the model for a derived context has been initialized, but before the model has been locked down and used to initialize the context. The default implementation of this method takes the IMappingConfiguration array passed in on construction and applies them. If no configuration mappings were passed it it does nothing.
Typically, this method is called only once when the first instance of a derived context is created. The model for that context is then cached and is for all further instances of the context in the app domain. This caching can be disabled by setting the ModelCaching property on the given ModelBuidler, but note that this can seriously degrade performance. More control over caching is provided through use of the DbModelBuilder and DbContextFactory classes directly.
- Parameters:
-
modelBuilder | The builder that defines the model for the context being created. |
T Highway.Data.DataContext.Reload< T > |
( |
T |
item | ) |
|
|
inline |
Reloads the provided instance of T from the database
- Template Parameters:
-
T | The Entity Type being reloaded |
- Parameters:
-
item | The T you want to reload |
- Returns:
- The T you reloaded
Implements Highway.Data.Interfaces.IDataContext.
T Highway.Data.DataContext.Remove< T > |
( |
T |
item | ) |
|
|
inline |
Removes the provided instance of T from the data context
- Template Parameters:
-
T | The Entity Type being removed |
- Parameters:
-
item | The T you want to remove |
- Returns:
- The T you removed
Implements Highway.Data.Interfaces.IDataContext.
T Highway.Data.DataContext.Update< T > |
( |
T |
item | ) |
|
|
inline |
Updates the provided instance of T in the data context
- Template Parameters:
-
T | The Entity Type being updated |
- Parameters:
-
item | The T you want to update |
- Returns:
- The T you updated
Implements Highway.Data.Interfaces.IDataContext.
Property Documentation
Event Documentation
The documentation for this class was generated from the following file:
- Highway.Data.EntityFramework/Contexts/DataContext.cs