Login Skip Navigation LinksWilsonORMapper > Examples > Persist 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

Persistence Examples

using System;
using Wilson.ORMapper;

namespace Wilson.Examples
{
  publicsealedclass Global
  {
    publicstatic ObjectSpace Manager; // See Initialization Example

    privatestaticvoid RunExamples() {
      // Create Object using ObjectSpace's GetObject method
      Contact contact = (Contact) Manager.GetObject(typeof(Contact));
      contact.Name = "Wilson, Paul";
      contact.Company = "WilsonDotNet.com";
      Manager.PersistChanges(contact); // Insert into Database
      int id = contact.Id; // Auto Identity assigned by Database

      // Retrieve Object by Primary Key using GetObject method
      contact = (Contact) Manager.GetObject(typeof(Contact), id);

      // Update Object changes using the PersistChanges method
      contact.Name = "Paul Wilson";
      Manager.PersistChanges(contact); // Update the Database
      
      // Delete Object using MarkForDeletion and PersistChanges
      Manager.MarkForDeletion(contact); // Mark for Deletion
      Manager.PersistChanges(contact); // Delete from Database
    }
  }
}