Documentation of free .NET O/R Mapper - Code Generator Invist

Invist supports a simple way to insert, update or delete data in an existing database. It is possible to combine a way with only use of one PersistenceManager.

Edit

Add new data entities to database

Storing data of a table in database is very simple. In the designer of Invist you can define the classname of a defined table in database. In our case we define the table "Products" as "Product" in .NET.

// Create Persistence Manager
var manager = new EntityPersistenceManager();

var employee = new Employee();
manager.Add( employee );

// Save changes to Manager
manager.PersistEntities();



Edit

Modify loaded data and Persist changes

Loading data from a table in database is very simple. In the designer of Invist you can define the classname of a defined table in database. In our case we define the table "Products" as "Product" in .NET.

// Load data and modify CountryName
var loader = new EntityLoader<Employee>();
var employees = new List<Employee>( loader.LoadEntities() );;
foreach( Employee employee in employees ) {
    employee.Country = "Germany";
}

// Create Persistence Manager
var connection = new Connection();
var manager = new EntityPersistenceManager();

// Add all Employees to manager
manager.AddRange(employees.ConvertAll<IEntity>( delegate(Employee employee) { return employee; }));

// Save changes to Manager
manager.PersistEntities();



Edit

Delete loaded data and Persist changes

Loading data from a table in database is very simple. In the designer of Invist you can define the classname of a defined table in database. In our case we define the table "Products" as "Product" in .NET.

// Load data and modify CountryName
var loader = new EntityLoader<Employee>();
var employees = new List<Employee>( loader.LoadEntities() );
foreach( Employee employee in employees ) {
    employee.MarkToDeleteOnPersist();
}

// Create Persistence Manager
var manager = new EntityPersistenceManager();

// Add all Employees to manager
manager.AddRange(employees.ConvertAll<IEntity>( delegate(Employee employee) { return employee; }));

// Delete data in database
manager.PersistEntities();



Edit

Persist entities to database async

Storing data of a table in database async is very simple. In the designer of Invist you can define the classname of a defined table in database. In our case we define the table "Products" as "Product" in .NET.

// Create Persistence Manager
var manager = new EntityPersistenceManager();

Employee employee = new Employee();
manager.Add( employee );

// Save changes in database async
manager.PersistEntitiesAsync();



NOTE: All examples can be used together with only ONE instance of EntityPersistenceManager. The EntityPersistenceManager controlls the inner instances of IEntity. On persiting the EntityPersistenceManager check each inner IEntity to insert, update, delete or to do nothing.

On call 'Persist' to save inner entities, the whole save-process run in one transaction. If any exception will occure, the EntityPersistenceManager runs a rollback. So the Database is always in a valid state.

ScrewTurn Wiki version 2.0.35. Some of the icons created by FamFamFam. Invist is powered by Mirko Meier