EntitySpaces

From Wikipedia, the free encyclopedia
Jump to: navigation, search
EntitySpaces
Developer(s) EntitySpaces, LLC
Stable release EntitySpaces 2010.1.1122.0 / 21 November 2010
Preview release EntitySpaces Beta 2011.0.0331.0
Written in C#
Operating system Cross-platform
Platform .NET 3.5+ and Mono
Type Object-relational mapping
License Licensed per developer seat
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.

Contents

[edit] History

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

[edit] Doodads

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

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

[edit] Providers Available

[edit] EntitySpaces Features

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

[edit] Examples

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

[edit] 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); 
    } 
}

[edit] 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); 
    } 
}

[edit] 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(); 
}

[edit] 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();

[edit] 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();

[edit] External links

[edit] See also

[edit] References

Personal tools
Namespaces

Variants
Actions
Navigation
Interaction
Toolbox
Print/export