Login Skip Navigation LinksWilsonORMapper > Examples > Initialize Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

Wilson ORMapper Examples Wilson ORMapper Examples

Initialize ObjectSpace

using System;
using Wilson.ORMapper;  

namespace Wilson.Examples
{
  publicsealedclass Global
  {
    publicstatic ObjectSpace Manager;

    [STAThread]
    privatestaticvoid Main() {
      // Use the config extension for xml so ASP.NET blocks their download
      string mappingFile = @"C:\Data\Examples\Contacts\Mappings.config";

      string exampleType = "ACCESS";
      switch (exampleType) {
        case "ACCESS" :
          // Create an instance of ObjectSpace for a Windows app using Access
          string connectAccess = @"C:\Data\Examples\Contacts.mdb";
          Manager = new ObjectSpace(mappingFile, connectAccess, Provider.Access);
          break;
        case "MSSQL" :
          // Create an instance of ObjectSpace for a Windows app using MS SQL
          string connectMsSql = "Server=(local);Database=Contacts;Trusted_Connection=True;";
          Manager = new ObjectSpace(mappingFile, connectMsSql, Provider.MsSql);
          break;
        case "MSWEB" :
          // Create an instance of ObjectSpace for a web or distributed application
          // Note that entity values are tracked for 20 minutes, like web sessions
          // Also note a timer is activated every 5 minutes to cleanup old values
          string connectMsWeb = "Server=(local);Database=Contacts;Trusted_Connection=True;";
          Manager = new ObjectSpace(mappingFile, connectMsWeb, Provider.MsSql, 20, 5);
          break;
        default :
          thrownew ApplicationException("Invalid Example Type: " + exampleType);
      }

      RunExamples();
    }
    
    private Global() {}
  }
}