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

VitaliyMF opened this issue Feb 22, 2017 · 1 comment

Custom object mapper for DbDataAdapter.Select result #28

VitaliyMF opened this issue Feb 22, 2017 · 1 comment


Copy link

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;
   } )

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
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
None yet

No branches or pull requests

1 participant