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

More Persistence Examples

using System;
using Wilson.ORMapper;

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

    privatestaticvoid RunExamples() {
      // Create Object using Explicit New Object Instantiation
      // StartTracking is only needed when using Explicit New
      // Required for User Key Types and Optional for Others
      Category category = new Category();
      category.Id = "P"; // Primary Key is assigned by the User
      category.Desc = "Paul's Friends";
      Manager.StartTracking(category, InitialState.Inserted);
      Manager.PersistChanges(category); // Insert into Database

      // Use QueryHelper with OPath-like ClassName.AliasName
      // Optional Method to avoid Explicit Table.Field Names
      QueryHelper helper = Manager.QueryHelper;
      string oldDesc = helper.GetExpression("Category.Desc", "Paul's Friends");
      string newDesc = helper.GetExpression("Category.Desc", "Personal");

      // This is a trivial example to illustrate these methods
      // Better usage is to update or delete multiple records
      // Or to update a field to a calculation instead of value
      Manager.ExecuteUpdate(typeof(Category), oldDesc, newDesc);
      Manager.ExecuteDelete(typeof(Category), newDesc);
    }
  }
}