Vx.Context - activa/iridium GitHub Wiki
- Constructors
- Methods
####Vx.Context(IDataProvider dataProvider)
Creates a data context for the given data provider.
####DataSet<T>()
IDataSet<T> DataSet<T>()
####Parameters None
####Description Returns a dataset for the given class type.
####CreateTable<T>(...)
IDataSet<T> CreateTable<T>(bool recreateTable = false, bool recreateIndexes = false)
####Parameters
######recreateTable
If true, the table will be dropped and recreated|
######recreateIndexes
If true, the indexes will be rebuilt|
####Description
Creates a table in the database for the given class type. If fields in the class are not yet in the database table, they will be created. However, changing the type of a field is not supported.
####Read<T>(key)
T Read<T>(object key, params Expression<Func<T, object>>[] relationsToLoad)
####Parameters
######key
For objects with a single primary key, this should be a single value of the same type as the primary key. For objects with a composite primary key, an anonymous object with properties having the same names as the primary keys should be passed
######relationsToLoad
One ore more relations to load after reading the record. The expression has to be in the form
obj => obj.Relation
####Return value
The object read from the database. If the object was not found, null
is returned
####Description
Reads a single object from the database.
####Examples
var customer = context.Read<Customer>(customerId);
//
var customer = context.Read<Customer>(customerId, c => c.Orders);
//
var rec = context.Read<ClassType>(new { Key1=1, Key2=2 });
####Read<T>(condition)
T Read<T>(Expression<Func<T,bool>> condition, params Expression<Func<T, object>>[] relationsToLoad)
####Parameters
######condition
An expression used to find a specific object in the database.
######relationsToLoad
One ore more relations to load after reading the record. The expression has to be in the form
obj => obj.Relation
####Return value
The object read from the database. If the object was not found, null
is returned
####Description
Reads a single object from the database based on a search expression. If more than one record matches the condition, only the first one is returned. You should make sure only one object matches the expression though.
####Examples
var customer = context.Read<Customer>(c => c.SSN == "999-99-9999");
//
var customer = context.Read<Customer>(c => c.Name == "John Doe", c => c.Orders);