Skip to content

Nested Properties#13

Closed
rlgnak wants to merge 4 commits intogregoryjscott:masterfrom
rlgnak:nested
Closed

Nested Properties#13
rlgnak wants to merge 4 commits intogregoryjscott:masterfrom
rlgnak:nested

Conversation

@rlgnak
Copy link
Copy Markdown
Contributor

@rlgnak rlgnak commented Feb 20, 2014

This adds the ability for simpler to create nested objects from a query. It works by matching matching a column name to the object properties and nested object properties.

Example 1

Given the following classes and query result a Person and a nested Pet object are created.

    public class Person
    {
        public string Name { get; set; }
        public int? Age { get; set; }
        public Pet Pet { get; set; }
    }

    public class Pet
    {
        public string Name { get; set; }
        public int? Age { get; set; }
    }
Name Age PetName PetAge
Jim 22 Spot 2

Example 2

Given the following classes and query result a Person and 2 nested Pet object are created.

    public class Person
    {
        public string Name { get; set; }
        public int? Age { get; set; }
        public Pet[] Pet { get; set; }
    }

    public class Pet
    {
        public string Name { get; set; }
        public int? Age { get; set; }
    }
Name Age Pet0Name Pet0Age Pet1Name Pet1Age
Jim 22 Spot 2 Fiddo 3

Example 3

Given the following classes and query result a Person and a nested dynamic object are created.

    public class Person
    {
        public string Name { get; set; }
        public int? Age { get; set; }
        public dynamic Pet { get; set; }
    }
Name Age PetName PetAge
Jim 22 Spot 2

Todo List

  • Add more tests

@gregoryjscott
Copy link
Copy Markdown
Owner

This is looking good. Let me know when you're ready for another review.

Moved all the reflection logic into ObjectMapping
Combined BuildDynamic and BuildTyped into BuildObject
Fixed failing tests
Added Additional tests
@rlgnak
Copy link
Copy Markdown
Contributor Author

rlgnak commented Feb 21, 2014

I added support for nested dynamic objects and moved all the reflection stuff into the mappingObject. I also made a change to how dynamics are created you just pass dynamic as a generic type when creating a task new BuildObject<dynamic>() let me know what you think.

I believe I have it to a point where a code review would be helpful.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, should be Vehicle.

@rlgnak
Copy link
Copy Markdown
Contributor Author

rlgnak commented Mar 18, 2014

I did some refactoring in an attempt to make the code more understandable and added more unit tests.

I also renamed ProcessColumnName to ParseColumnName and created a set of unit tests for it. I'm not sure that is much better, but I'm stumped on how to make it any clearer,

@gregoryjscott
Copy link
Copy Markdown
Owner

This PR will be re-created after Simpler.Data is resurrected. See #19 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants