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

Comments

Projects
None yet
1 participant
@VitaliyMF
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@VitaliyMF

VitaliyMF Mar 3, 2017

Contributor

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

Contributor

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