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

Retrieve Collection Examples

using System;
using System.Data;
using Wilson.ORMapper;

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

    privatestaticvoid RunExamples() {
      // Retrieve Collection of All Contact Objects -- Can One-Way Bind ObjectSet
      ObjectSet allContacts = Manager.GetObjectSet(typeof(Contact), String.Empty);

      // Retrieve Collection of Contact Objects that satisfy the given WhereClause
      QueryHelper helper = Manager.QueryHelper;
      string where = helper.GetExpression("Contact.Company", "WilsonDotNet.com");
      ObjectSet someContacts = Manager.GetObjectSet(typeof(Contact), where);

      // Retrieve Collection of Contact Objects with WhereClause and SortClause
      string sort = helper.GetFieldName("Contact.Name") + " ASC";
      ObjectQuery sortQuery = new ObjectQuery(typeof(Contact), where, sort, 0, 1);
      ObjectSet sortContacts = Manager.GetObjectSet(sortQuery);

      // Retrieve 3rd Page of 25 Contact Objects with WhereClause and SortClause
      ObjectQuery pageQuery = new ObjectQuery(typeof(Contact), where, sort, 25, 3);
      ObjectSet pageContacts = Manager.GetObjectSet(sortQuery);

      // Retrieve DataSet of All Contact Objects -- Optionally Specify Field List
      string[] fields = newstring[] {"ContactId", "ContactName"};
      DataSet partContacts = Manager.GetDataSet(typeof(Contact), String.Empty, fields);

      // Retrieve ObjectReader Cursor of All Contact Object -- Custom Processing
      ObjectReader cursor = Manager.GetObjectReader(typeof(Contact), String.Empty);
      while (cursor.Read()) {
        Contact contact = (Contact) cursor.Current();
      }
      cursor.Close();
    }
  }
}