EntitySpaces
EntitySpaces is an object-relational mapping tool, whose architecture can be used when writing an ASP.NET, .NET Framework or .NET Compact Framework application. The architecture is provider independent, allowing developers to run the same binary code against any of the supported databases. EntitySpaces works with both C# and VB.NET and uses no reflection and no XML files.
Although EntitySpaces targets both ASP.NET and Windows.Forms projects, DotNetNuke module developers can use the architecture as an alternative to the DotNetNuke DAL. Many of the features listed below, including important ones like transactions, are not available when using the DotNetNuke DAL API.
History
EntitySpaces, LLC
On January 18, 2006 a filing was made for the formation of "EntitySpaces, LLC", a limited liability company. On January 23, 2006 EntitySpaces, LLC officially became a legal entity. In February, EntitySpaces, LLC put together a commercial offering for the EntitySpaces .NET architecture.
Doodads
The dOOdads .NET Architecture was created by Mike Griffin and, in many ways, is the progenitor of EntitySpaces. During the dOOdads architecture development and evolution, a lot was learned from the community, much of which has made its way into EntitySpaces.
The dOOdads architecture is written natively in both C# and VB.NET. The dOOdads .NET architecture also comes with MyGeneration templates that generate native C# or VB.NET dOOdad classes.
The EntitySpaces binaries are written in C#. Templates are available to generate both C# and VB.NET concrete and abstract classes, so EntitySpaces is fully supported for both languages, but native VB.NET binaries are not provided.
Providers Available
- Microsoft SQL Server / SQL CE
- Microsoft Access
- Oracle
- MySQL
- VistaDB
- PostgreSQL
EntitySpaces Features
Feature |
Description |
|---|---|
Mono Support |
Runs MySQL and VistaDB under Mono. |
Compact Framework Support |
In version 1.6.0 and onwards, EntitySpaces incorporated full support for Microsoft's .NET Compact Framework, the incorporatation SQL CE and VistaDB Database support for Mobile/CE applications. |
Medium Trust Support |
Allows the use of zero reflection through the use of a Medium Trust Loader, and works in any environment. |
Design Time Data Binding |
Has design time data binding support for grids, detail forms, and other controls in ASP.NET. |
Hierarchical Data Models |
The EntitySpaces Hierarchical Template uses the foreign keys in a database to automatically build the hierarchical object model. |
Dynamic Query API |
Straight-forward syntax for generating outputs with the power of SQL without the need for SQL Views or queries. |
Binary and XML Serialization |
Proxy Stubs can be used to serialize and deserialize data on either side of a Web Service. |
Data Provider Independence |
Provider independence allows the database to be switched to a different provider at run-time. |
Two Different Transaction Models |
You can use ADO.NET connection-based transactions or COM+ distributed transactions. |
Saving via Stored Procedures or Dynamic SQL |
|
Generated from your Database Schema |
Generates required classes for managing a database using MyGeneration. |
No XML mapping files |
|
LINQ Support for Collections |
|
Regenerate Without Losing Custom Business Logic |
Custom classes are partial classes on the generated classes and are never overwritten. |
Admin Grid Template Suite for ASP.NET |
Generates maintenance pages for a database. The template allows sorting, searching, paging, editing, and more. |
Admin Grid Template Suite for DotNetNuke |
Generates user controls contained in a loader to be loaded in a DotNetNuke module. |
Examples
The following are examples of using EntitySpaces with the Northwind Database.
Loading a Collection
This sample loads all Employees in the database.
EmployeesCollection coll = new EmployeesCollection();
if(coll.LoadAll())
{
foreach (Employees emp in coll)
{
Console.WriteLine(emp.LastName);
}
} Querying a Collection
This sample loads all Employees whose last name starts with “Smi”.
EmployeesCollection coll = new EmployeesCollection();
coll.Query.Where(coll.Query.LastName.Like("Smi%")
if(coll.Query.Load())
{
foreach (Employees emp in coll)
{
Console.WriteLine(emp.LastName);
}
} Saving a Collection
Here the Employees are being transferred to Indianapolis. You never call Save on the single entity when it lives in a collection. Save will commit all modified, added, and deleted rows.
EmployeesCollection coll = new EmployeesCollection();
if(coll.LoadAll())
{
foreach (Employees emp in coll)
{
emp.City = "Indianapolis";
}
coll.Save();
} Adding new records through a Collection
Here two new Employees are being added and saved.
EmployeesCollection coll = new EmployeesCollection();
Employees emp = coll.AddNew();
emp.FirstName = "Joe";
emp.LastName = "Smith";
emp = coll.AddNew();
emp.FirstName = "Sue";
emp.LastName = "Smith";
coll.Save(); Deleting a record through a Collection
This example demonstrates the use of FindByPrimaryKey to locate a particular Employee in the collection, then marks it as deleted, and finally saves the collection.
EmployeesCollection coll = new EmployeesCollection();
coll.LoadAll();
Employees emp = coll.FindByPrimaryKey(41);
if(emp != null)
{
emp.MarkAsDeleted();
coll.Save();
} If you need to delete all of the records from a table, you use the MarkAllAsDeleted method as follows:
EmployeesCollection coll = new EmployeesCollection();
coll.LoadAll();
coll.MarkAllAsDeleted();
coll.Save(); External links
- EntitySpaces Website
- EntitySpaces MyGeneration Presentation
- EntitySpaces CodeSmith Presentation
- MyGeneration - Code Generation and OR Mapping
See also
- List of object-relational mapping software