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

Invist supports three different ways to load data from the persistent medium. The most common way to obtain data is to load it from an existing table. These data can be modified or deleted. The second way is to define a view in the database. If a view is created in database, Invist creates a readonly-entity. This method of loading data is the same as loading data from a table. The third method is to load data by using a stored procedure. Stored procedures are created as a class.

Edit

Loading data of a table

Loading data from a table is very simple. In the designer of Invist you can define the classname independent of the tablename. In the following example we define the table "Employees" as "Employee" in .NET. The sample demonstrates how to load all entries of a table. To see how to filter the result see filters.

var loader = new EntityLoader<Employee>();
IEnumerable<Employee> employees = loader.LoadEntities();



Edit

Loading data of a view

Loading data from a view is as simple as loading from a table. The only difference between a view and a table is that a view-class is readonly. This means the view-class contains no setter for a property. In the following example the view "Invoices" is defined as "Invoice" in C#.

The sample demonstrates the loading of all entries of a view. To see how to filter the result see filters.

var loader = new EntityLoader<Invoice>();   
IEnumerable<Invoice> invoices = loader.LoadEntities();



Edit

Loading data by using a stored procedure

Generated stored procedures has the same logic like a Command. The main different to a not generated Command is, that the parameters are typed properties. The following example shows the usage of stored procedure "Sales By Year" called as "SalesByYearCommand" with two input parameters. It is required to assign a IConnection to use. So ensure that you have in your own stored procedures a parameter named "Connection".

SalesByYearCommand procedure = new SalesByYearCommand();
procedure.Beginning_Date = new DateTime( 1950, 1, 1 );
procedure.Ending_Date = DateTime.Now;
            
IConnection connection = new Connection();
procedure.Connection = connection;
connection.Open();

using( IDataReader reader = procedure.ExecuteReader( CommandBehavior.CloseConnection ) ) {
    // Implement code     
}

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