NPersistence Reference Guide
Specifies the type of the map key for associations of type System.Collections.Generic.Dictionary.

The map key can be a basic type, an embeddable class, or an entity. If the map is specified using generics, the MapKeyClass annotation and associated type need not be specified; otherwise they must be specified.

The MapKeyClass annotation is used in conjunction with ElementCollection or one of the collection-valued relationship annotations (OneToMany or ManyToMany). The MapKey annotation is not used when MapKeyClass is specified and vice versa.

Examples

CopyC#
Example 1:

[Entity]
public class Item {
   [Id] int id;
   ...
   [ElementCollection(targetClass=String.class)]
   [MapKeyClass(String.class)]
   Dictionary images;  // map from image name to image filename
   ...
}

Example 2:

// MapKeyClass and target type of relationship can be defaulted

[Entity]
public class Item {
   [Id] int id;
   ...
   [ElementCollection]
   Dictionary<String, String> images; 
    ...
 }

 Example 3:

 [Entity]
 public class Company {
    [Id] int id;
    ...
    [OneToMany(targetEntity=com.example.VicePresident.class)]
    [MapKeyClass(com.example.Division.class)]
    Dictionary organization;
 }

 Example 4:

 // MapKeyClass and target type of relationship are defaulted

 [Entity]
 public class Company {
    [Id] int id;
    ...
    [OneToMany]
    Dictionary<Division, VicePresident> organization;
 }

Namespace: NPersistence
Assembly: NPersistence (in NPersistence.dll) Version: 2.0.0.0 (2.0.0.0)

Syntax

   
 C# 
public sealed class MapKeyClass : Attribute

Members

         
 All Members  Constructors   Fields  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
MapKeyClass()()()()
Initializes a new instance of the MapKeyClass class
MapKeyClass(Type)
Initializes a new instance of the MapKeyClass class
Value
(Required) The type of the map key.

Inheritance Hierarchy

System..::..Object
  System..::..Attribute
    NPersistence..::..MapKeyClass

See Also