Nested objects / unflattening objects

Jul 6, 2010 at 10:42 PM
Edited Jul 6, 2010 at 10:43 PM

I've been working with your tool for a few days now, and I've come across a scenario that I thought I'd run by you. I have a business object that has a property that is itself an object. In normal usage, I'd address it as follows:

Foo.Bar.Name = "Test";
Foo.Id = 1;

Those properties above would come through "ID" and "BarName" (a column alias) in my SQL query.

In reality, that nested object is present in many other objects, and what I'd like to avoid doing is repeating my mapping code in every mapper. Because of how the field name alias comes through, I can't just use the mapper I have for the standalone Bar object (its fields don't have the "Bar" prefix).

In the past I've used mapping utilities like ValueInjecter and AutoMapper to map to my business objects from Linq-to-SQL objects, but those won't help me since we're going from a reader to an object. I thought I'd see if you had any ideas.