Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
The Item Type Attribute
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Attributes > The Item Type Attribute

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

The [ItemType] attribute is used to specify the type of collection elements. For Collection types that implement IDictionary, the [ItemType] attribute can be used to specify the type for both the key and the value elements of the dictionary. Whenever a Collection contains instances of a ValueType, the [ItemType] attribute specification is required. If an [ItemType] attribute is not specified, the Collection may contain instances of any user-defined persistent class.

The [ItemType] attribute is applied to a class field of a Collection type. For a simple collection, it takes the following general form:
[OpenAccess.ItemType(Type ElementType)]
For fields of IDictionary types, the types for both the key and value are specified:
[OpenAccess.ItemType(Type KeyType, Type ValueType)]
There are also constructors with a string parameter instead of Type. The types are specified as fully qualified type names. These constructors are used for Visual Basic. You will find the descriptions for the [ItemType] attribute in the OpenAccess ORM .NET API Reference for the class ItemTypeAttribute.

The following example specifies an ArrayList field whose elements are restricted to type Address:

 

Copy Code
[OpenAccess.Persistent]
class Company
{
  // . . .
  [OpenAccess.ItemType(typeof(Address))]
  ArrayList addresses;
  // . . .
}