Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom object mapper for DbDataAdapter.Select result #28

Closed
VitaliyMF opened this issue Feb 22, 2017 · 1 comment
Closed

Custom object mapper for DbDataAdapter.Select result #28

VitaliyMF opened this issue Feb 22, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@VitaliyMF
Copy link
Contributor

@VitaliyMF VitaliyMF commented Feb 22, 2017

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>).

@VitaliyMF VitaliyMF self-assigned this Mar 3, 2017
@VitaliyMF VitaliyMF added this to the 1.0.1 milestone Mar 3, 2017
VitaliyMF added a commit that referenced this issue Mar 3, 2017
@VitaliyMF
Copy link
Contributor Author

@VitaliyMF VitaliyMF commented Mar 3, 2017

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.