So the exciting news is that Nvigorate is stable enough for an Alpha release which is now available for download via CodePlex. Obviously, being in Alpha means that even though the unit tests all appear to be passing, it's far from done.
First off, I'll be updating the Nvigorate.dll assembly in the Alpha release every few days as I continue to add tested functionality to the code base. I had a nice little break-through today and got some additional support for inheritance in the ORM done primarily in the area of discrimination (more on that in a few).
It's been well over a month since the last status posting, mostly due to the birth of our first born son, and his subsequent week in the hospital (all is better now). So, whenever he lets me now, I've been getting some work done...
I've also been busy working on the wiki and a demo MVC application. Neither are pinnacles of software documentation but I'm trying to follow the excellent user guides employed by Nate Kohari of Ninject and the Fluent NHibernate team (though I like my API better, their documentation is great).
What's Still In The Works
Last time I had a status blog, I still hadn't delivered
- Count functionality to DatabaseRepository
- Constraining parent records by child selection criteria
- Advanced sub-query behavior (i.e. Having)
- An updated approach to getting total records when paging
- old Nvigorate had this but all the new features broke it : (
- it's harder than it sounds when you can have nested paging
- More discriminator support
What's Happened Since
I really want to show off some of the fluent mapping API because I think it reads well but obviously need outsiders to take a look and tell me what's unclear.
While there are several simple conventions in place so that the API will assume things like class names and table names match unless you specify otherwise, I'm especially happy to announce another usability feature I've added to compliment Nvigorate (but is totally optional). I'll be providing T4 templates to assist with the user experience. In the realm of fluent maps, it will allow you to completely eliminate all magic strings from your maps, get intellisense for the database schema, and get compile time checking of your maps.
Unfortunately, it's late so the example I'm going to post here will be largely meaningless but at least it demonstrates the API calls.
1: public class EmployeeMap : FluentMap<Employee>
2: { 3: public EmployeeMap()
4: { 5: var parentTable = Inherit<PersonMap, Person>("Person"); 6:
7: var employee = MapTable<DatabaseSchema.nvigorate.employeeSchema>();
8:
9: employee.Assign(e => e.Id, t => t.EmployeeId).AsKey().ReadOnly();
10: employee.Assign(e => e.Department.Id, t => t.DepartmentId);
11: employee.Assign(e => e.JobTitle.Id, t => t.JobTitleId);
12: employee.Assign(e => e.Manager.Id, t => t.ManagerId);
13: employee.Assign(e => e.SocialSecurity, t => t.EmployeeSocial);
14:
15: employee.JoinFromInherited(
16: parentTable,
17: JoinType.Left,
18: employee.PropertyCriteria(e => e.SocialSecurity)
19: .EqualTo(parentTable.Property(p => p.SocialSecurity))
20: );
21:
22: MapChildren(e => e.Employees)
23: .ForeignKey(e => e.Id, e => e.Manager.Id);
24:
25: MapParent(e => e.Manager)
26: .ForeignKey(e => e.Manager.Id, e => e.Id);
27:
28: MapParent(e => e.Department)
29: .ForeignKey(e => e.Department.Id, d => d.Id);
30:
31: MapParent(e => e.JobTitle)
32: .ForeignKey(e => e.JobTitle.Id, j => j.Id);
33: }
34: }
There are several things worth a quick mention.
I chose this map because there's a lot going on in it.
First off, it's inheriting from a map to another type because Employee inherits from that other type and they share a table in common.
Second, notice that MapTable is taking a type argument? That's the class that represents the database schema and is how you can (optionally) make use of schema classes generated by the template.
In each Assign, the first lambda points to the object's property being mapped and the second one points to the corresponding column.
You'll notice that a lot of the Assigns are actually pointing to the property of a property. This one of the way Nvigorate handles foreign keys.
Each of the MapChildren/MapParent calls establishes a two-way relationship in Nvigorate. Provided that you include a 'back reference' property on your domain model, Nvigorate will populate these back references for you.
In the next few weeks I hope to polish up some of the other areas of the ORM to leverage the database schema classes and perhaps introduce some additional helpers through code gen. I'll also be working a lot on documentation as well as adding a persistence pipeline (to allow you to get hooks into the persistence process) and introducing the first version of the Validation namespace.
Tags: