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
Milestone

Comments

@VitaliyMF
Copy link
Contributor

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
Copy link
Contributor Author

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
Development

No branches or pull requests

1 participant