Thursday, October 16, 2008

ORM101: An Introduction to Object Relational Mappers

I gave a presentation at the Wellington Dot Net User Group last night. I have been asked to supply my notes.

Steps for downloading and installing:

  1. Download
  2. Install
  3. Add External Tool command to Tools menu
    • Title: SubSonic DAL
    • Command: SubCommander/sonic.exe
    • Arguments: generate /out Generated /lang VB
    • Initial directory: ($ProjectDir) Use
    • Output window Prompt for arguments
  4. Add Subsonic Toolbar Customise Add External Tool 1

Steps to Generating DAL classes:

  1. Open new Web Application Project (AdventureWorks)
    1. Open IIS Manager
    2. Enable Directory Security, Integrated Windows Authentication
  2. Add VB Class Library Project (AdventureWorks.DataAccess)
    1. Ensure Project Root Namespace = “AdventureWorks”
    2. Add Reference to Subsonic.dll, System.Configuration, System.Web
    3. Delete Class1.vb
    4. Edit app.config
    5. Add section reference to
    6. Add a connection string for each one of your providers
    7. Define Subsonic Service Provider(s) (one per database):
    8. Add Generated folder to DataAccess folder (or project)
    9. Execute Subsonic
  3. Add Existing Item(s)
  4. Build

Using in Web Project:

  1. Add a Business Logic Layer (Class Library)
    • Add References to SubSonic.dll, AdventureWorks.DataAccess
    • Rename Class1 as Product
    • Define the class as Public, decorated with
    • Define methods as Public, decorated with
    • Save and Compile
  2. Add a Grid to a Web Page
    • Add Reference to Subsonic.dll
    • Add SubsonicSection to web.config
    • Add SubsonicProvider to web.config
    • Add ConnectionString to web.config. Highlight difference in user ID.
    • Set Default.aspx as Start Page
  3. Build and Run (F5)

No comments:

Post a Comment