-
Notifications
You must be signed in to change notification settings - Fork 7
Configuration Basics
Your IConfiguration provides information regarding which classes are in your domain and how those classes are mapped to the database.
Assuming you're inheriting from DefaultConfiguration or ConfigurationBase you'll be able to access the Add, AddNamespaceOf and Setup methods from within your constructor. These methods allow you to quickly add the domain classes. Note, that they will only be added once, irrespective of how many times the method is called.
Add and AddNamespaceOf are very simple, just telling your Configuration that a class should be mapped by convention.
Setup, on the otherhand* allows you to modify the mapping. Setup() returns the IMap for the table which then gives you access to the Columns, Indexes, Foreign Keys as well as Table specific properties (such as Name, Schema)
We suggest following intellisense to see what can be achieved but some common examples that we always seem to perform are:
this.Setup<Feedback>().Property(f => f.Content).MaxLength();
this.Setup<Foo>().Property(f => f.Total).Ignore();
this.Setup<Person>().Index(a => new { a.EmailAddress });
this.Setup<Person>().Index(a => new { a.FirstName, a.Surname });
this.Setup<Person>().Index(a => new { a.EmailAddress }, true);
this.Setup<Todo>().Table("Todos")
* Setup calls Add internally