Welcome Guest, you are in: Login

dbones docs


Navigation (ArmChair)

Search the wiki


Modified on 2017/03/19 13:16 by Dave Categorized as Uncategorized

Table of Contents [Hide/Show]

Work in progress


This article covers a new concept called a ClassMap, which allows us to provide minimal meta data about a single class.


the ClassMap allows you to define the ID and Revision fields for a single class in 1 place. the idea is by keeping it together for registration it may clean up the code.

Consider we have a class which does not follow the standard conventions.

When to use

try to use conventions either the default ones or register conventions which can be applied across all you domain classes.

only use classmaps for classes which diverge from the conventions.


for example:

public class CustomThing
    public string EpicId { get; set; }
    public string IAmARevision { get; set; }
    public string Name { get; set; }

we need to tell Armchair about these property names for the ID and Revision. This could be done by setting it against the IdAccessor and RevisionAccessor, however we can supply a class map.

example of a class map.

public class CustomThingMap : ClassMap<CustomThing>
    public CustomThingMap()
        Id(x => x.EpicId);
        Revision(x => x.IAmARevision);

this class holds 4 important bits of data

  • 1 the Type
  • 2 the Id field name
  • 3 the Revision field name.
  • 4 any index's

in order to use this Class map we need to register it like so:

//class maps inform Armchair of all the persistable types.
//this allows for queries such as find all objects
//you can still persist types without having a classmap
Database.Register(new ClassMap[] { new CustomThingMap(), new PersonMap() });

note as we register the class map, it will also be used to inform ArmChair of the Type, which can then be used with LINQ Queries, more on that on the LINQ Query page
dbones docs, is a sub-site of dbones.co.uk, all its content belongs to dbones.co.uk, this also includes logo's.