My favorites | Sign in
Project Home Wiki Source
Search
for
TechnicalOverview  
Technical overview of the Object Relational Mapper (ORM) tool.
Featured
Updated Aug 6, 2009 by matthewchoinski





Overview

The Object Relational Mapper (ORM) Project is a simple object relational mapper tool for Microsoft .NET projects. The ORM tool generates object classes and database stored procedures by evaluating a target database.



Configuration

The ORM tool usage must be configured in the project's web.config file, as shown in the following:

<configuration>

  <configSections>
    <section
      name="MappingConfiguration"
      requirePermission="false"
      type="ObjectRelationalMapping.Configuration.MappingSection, ObjectRelationalMapping" />
  </configSections>

  <MappingConfiguration
    ApplicationNamespace="MyProjectNamespace"
    DatabaseConnectionString="Data Source=MyDatabaseServer; Database=MyDatabase; Integrated Security=true;" 
    ExcludePrefix="fk_,pk_" 
    ExecuteGeneratedSql="False"
    ExcludeTable="MyStatusTable" />

</configuration>

The settings within the configSections cannot be changed. The MappingConfiguration section provides optional attributes to customize the generated actions and outputs.



Attributes

Name Type Usage Description
ApplicationNamespace String Required The name-space for the target project. The ORM tool uses the specified name-space for the generated classes. For example, the ORM tool will use the specified name-space of MyNamespace and generate a class for the MyTable user-table with the name-space of namespace MyNamespace.MyTable.
DatabaseConnectionString String Required The target database connection string.
ExcludePrefix String Optional The ORM tool will remove any prefixes used in user-table columns for generated class attributes. For example, a user-table column of fk_MyForeignKey will be generated as a class attribute of MyForeignKey. Values must be separated by a comma.
ExecuteGeneratedSql Boolean Optional The ORM tool will execute the generated stored procedures by default. An attribute value of False will prevent the execution of the generated stored procedures.
ExcludeTable String Optional The ORM tool will not generate any classes or stored procedures that are specified. Values must be separated by a comma.




Output

The ORM tool generates class objects, directories and stored procedures based on the specified configuration.



Directories

Name Description
/Models The directory that may contain extended and other customized class objects.
/Models/Generated The directory that contains all generated class objects. Note: Any changes to files contained in this directory will be over-written when the ORM tool is invoked.
/Models/Generated/Helper The directory that contains the Helper classes. Specifically, this directory contains the Entity (Base) and SqlHelper classes.
/Models/Generated/Sql The directory that contains the generated stored procedures.




Files

Name Description
Entity.cs The file contains the base class, which all generated classes are derived from, and a collection class.
SqlHelper.cs The file contains a wrapper class for common database operations.




Stored Procedures

Name Parameters Usage Description
Delete Primary Key Required Deletes a single record based on the primary key parameter from a user-table.
Insert Column(s) Inserts a single record based on the parameter(s) into a user-table.
Paging @MaximumRows Required Returns a group of records based on the parameters from a user-table.
@StartRowIndex Required
Select Primary Key Optional Returns a single record based based on the parameter from a user-table. Or returns all records from a user-table when the parameter is NULL.
Update Column(s) Updates a single record based on the parameter(s) in a user-table.




Helper Classes

Entity

An abstract class that provides basic data manipulation methods. All generated classes are derived from this class.

Methods

Name Access Returns Description
FetchCount Public Static Integer ...
Insert Protected Static Integer ...
Remove Protected Static Void ...
Update Protected Static Void ...




EntityCollection

A partial class derived from CollectionBase that provides support for handling strongly-typed collections. Specifically, the class only supports collections of objects derived from the Entity class.

Methods

Name Access Returns Description
Add Public Integer ...




SqlHelper

An internal static wrapper class that provides common database methods.

Methods

Name Access Returns Description
ExecuteNonQuery Internal Static Integer ...
ExecuteReader Internal Static SqlDataReader ...
ExecuteScalar Internal Static Object ...
PrepareCommand Private Static Void ...





Sign in to add a comment
Powered by Google Project Hosting