Lookupset Items in the .Net SDK

Overview

In RM 82 Lookup Set Items were freed from the restrictions of being a child object type.  This means that a lookup set item is now a main object, at the same level as the lookup set itself.  Why was this done?  Mainly to allow for large lookup sets.  The parent child relationship among RM objects has practical limits on the number of children a main object can have.

Adding a new lookup item

The new way to add a new item is to instantiate it using the lookup set as the constructor parameter, for example:

LookupSet lookupSet = new LookupSet(database, 9000000000);
LookupItem lookupItem = new LookupItem(lookupSet);

lookupItem.Name = "My Test";
lookupItem.Save();

Fetching lookup items

You can get a list of lookup items just as you would any other main object type (e.g. record or location), using the TrimMainObjectSearch, as seen here.

TrimMainObjectSearch lookupItemSearch = new TrimMainObjectSearch(database, BaseObjectTypes.LookupItem);
lookupItemSearch.SetSearchString("set:9000000000");

foreach (LookupItem item in lookupItemSearch)
{
    Console.WriteLine(item.Name);
}
Written on October 9, 2015