Welcome Guest, you are in: Login

dbones docs

RSS RSS

Navigation (ArmChair)





Search the wiki
»

Id Field Name

RSS
Modified on 2014/09/14 22:54 by Dave Categorized as Uncategorized

Overview

In this article we will look at support for the Id Field, and how we can customize it.

Id Field

The Id Field is nothing new, buts lets quicky recap to what is is

"Saves a database ID field in an object to maintain identity between an in-memory object and a database document." - adapted from PoEAA

This is a required field and it has to be located on the Aggregate root

Supported Patterns

Out of the box ArmChair will try and find the Id Field for you and it will check for the following

  • Field called "id" or "_id"
  • Auto Property called "Id" or "ClassNameId"

Setting the Id for a Single Type

Its quite simple, all we have to do is tell the IdAccessor what the Field is called.

You only need to call this setup once (and only if the auto scanning pattern does not support your field)


//Via a auto-property
Database.Settings.IdAccessor.SetUpId<Person>(x => x.NameOfId);

//via the fields name
Database.Settings.IdAccessor.SetUpId<Person>("NameOfId");

//via the field info
Database.Settings.IdAccessor.SetUpId<Person>(typeof(Person).GetField("NameOfId"));

dbones docs, is a sub-site of dbones.co.uk, all its content belongs to dbones.co.uk, this also includes logo's.