EntitySpaces

EntitySpaces
Developer(s) EntitySpaces, LLC
Stable release
EntitySpaces 2012.1.0930.0 / 4 October 2012
Written in C#
Operating system Cross-platform
Platform .NET 3.5+ and Mono
Type Object-relational mapping
License Modified BSD License
Website http://www.entityspaces.net

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.

On September 21, 2012, EntitySpaces announced they would dissolve on December 31, 2012 and their products would transition to open source.[1]

Doodads

The dOOdads .NET Architecture was created by Mike Griffin[2] 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.[3]

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.[4]

Providers Available

EntitySpaces Features

Feature Description
Mono Support[7][8] Runs MySQL and VistaDB under Mono.
Compact Framework Support In version 1.6.0 and onwards,[9] 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[10] 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 Straightforw

Examples

The following are examples of using EntitySpaces with the Northwind Database.

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.MarkAllAsDeleted(); 
coll.Save();

See also

References

External links

This article is issued from Wikipedia - version of the 11/22/2014. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.