Skip to content

Custom object mapper for DbDataAdapter.Select result #28

Closed

Description

@VitaliyMF

Currently DbDataAdapter.SelectQuery can perform simple column-to-property POCO mapping.
In some cases single query result should be mapped to more complex structure with nested objects.

This is possible to achieve with custom mapping handler, smth like this:

DbDataAdapter dbAdapter;
var myModel = dbAdapter.Select(...)
   .Map( (context) => {
     var res = new MyModel();
     context.MapTo(res);   // populate properties of main model
     context.MapTo(res.Submodel);  // populate properties of submodel
     return res;
   } )
   .Single<MyModel>();

Also context.MapTo should have an overload that will accept column-to-property map (Dictionary<string,string>).

Activity

  1. self-assigned this
    on Mar 3, 2017
  2. added this to the 1.0.1 milestone on Mar 3, 2017
  3. VitaliyMF commented on Mar 3, 2017

    @VitaliyMF
    ContributorAuthor

    Added DbDataAdapter.SelectQuery.SetMapper method that accepts custom mapping handler.
    Shipped in 1.0.1

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions