How to use Automapper to map multiple DataTables to an object - automapper

I've used Automapper before to map DataTable objects to a DTO object like this:
AutoMapper.CreateMap<IDataReader, MyDTO>();
Now I've run into a case where I have three DataTable objects that map to one DTO object. I can't use the simple case above because I have three sources with the same type.
Is there a way to specify some additional information, like the table name, to determine the correct mapping?

Related

Can jOOQ object mapping configured ensure all fields of POJO are set?

I'm mapping jOOQ results into POJOs.
I'd like to avoid having columns of the result not being mapped because of a typo/mismatch between field name and column name.
Is there a way to configure jOOQ to verify each field of the POJO is properly set ?
This cannot be done out of the box, but you can implement a custom RecordMapperProvider that implements the desired checks:
https://www.jooq.org/doc/latest/manual/sql-execution/fetching/pojos-with-recordmapper-provider

Dozer mapper to map without mapping file

My source and target beans would have same number of objects and names of them. Also these objects would be created on the fly according to each category (models). Based on this case can I map my beans without a mapping file. If so can I have an example.

is there an AutoMapper merge function?

AutoMapper Beginner Question:
I was hoping AutoMapper would let me merge properties from a DTO back into an existing business object. I don't see anything like that. AutoMapper.Map() generates a new object and populates it, but I need to copy DTO changes back into the original business object.
Is there an Map function that takes a source and target object?
The Map method is overloaded. You can use Map(src, dst).

How can I combine/split properties with AutoMapper?

we're using Automapper (http://automapper.codeplex.com/) to map between entities and dto's. We have a situation where one property on an entity corresponds to three different properties on the dto, and we need to write some custom logic to do the mapping. Anyone know how we can do that? (We need to map both ways, from entity and from dto).
I notice that AutoMapper supports custom resolvers to do custom mapping logic, but as far as I can tell from the documentation, they only allow you to map a single property to another single property.
Thx
You can create a custom type converter. It allows you to define a converter for an entire type, not just a single property.

ExecuteJoinedDataSet but with Where()

I did some searching and see that ExecuteJoinedDataSet will not work with the Where clause in 2.1. If I want to query a table with WHERE, but want the FK objects values to be bindable is the easiest way to just create a custom class(my table has tons of FK references).
Could you give us an example of what kind of query you are trying to write? If you are just trying to return a DataTable without creating a custom class just write your query and use the ExecuteReader which Returns an IDataReader. The IDataReader is bindable and if you need more you can just load it into a DataTable.

Resources