2
votes

I am currently using auto mapper and I think it is a good tool but I don't like how it can't handle view model to domain situations. It kinda sucks that I have to go in the automapping and map each one.

I been looking around and been reading about valueinjecter and how it can handle this. I am wondering though can it do these features what automapper has?

  1. Can you make something like resolvers and formatters?
  2. Can you combine values. For instance on the client side I have a datetime but it is broken into 2 different textboxes(one has a timepicker one has a datepicker). Of course in the database it is stored as one field.

So in my domain(what is later used with nhibernate) I have DateTime DateChoosen. In my view model I would have String Date, String Time.

Right now in automapper I have a resolver(or formatter I can't remember) that takes both of the view model values and converts it into a DateTime and then maps it to the domain.

Can I do something like this in valueinjecter?

I also been looking around and found this Automapper simulation with the ValueInjecter. I am wondering if this would have all the automapper features or if it just makes the syntax look like automapper.

If it actually uses automapper too, does anyone know if they keep using the most current versions?

1
try this Automapper simulation: valueinjecter.codeplex.com/releases/view/…Omu
I will check it out. I just ended up sticking with automapper for now. The case that I thought I needed for valueinjector has nhibernate domains. So right now I am sure if I map the Id from Vm to Domain would it try to create a new record in my db or would it update the old one? So till I get more time to play with scenarios like this I have to put valueinjector on my todo list(otherwise I will never get my project done)chobo2

1 Answers

0
votes

It's a different concept, it's not the exact same thing so it doesn't have formatters and resolvers, it only has ValueInjections which are applied when injecting from one object to another

the exact scenario that you are describing is shown in prodinner sample, here:

http://code.google.com/p/prodinner/source/browse/trunk/WebUI/Mappers/DinnerMapper.cs

DinnerMapper inherits this:

http://code.google.com/p/prodinner/source/browse/trunk/WebUI/Mappers/Mapper.cs