Re: Sample/Documentation for IMappingOperationOptions ?

4,155 views
Skip to first unread message

Patrick Steele

unread,
Jul 3, 2012, 5:52:16 PM7/3/12
to automapp...@googlegroups.com
I don't know if the automapper wiki
(https://github.com/AutoMapper/AutoMapper/wiki) is up-to-date, but
there's a few options like:

Specifically defining which source field will be used in destination mapping:
.ForMember(d => d.Foo, o => o.MapFrom(s => s.FooSource))

Ignoring a property:
.ForMember(d => d.SecurityLevel, o => o.Ignore())

Defining a substitute value when the source property is null:
.ForMamber(d => d.Age, o => o.NullSubstitute(18))

There's also options like:
.ResolveUsing (use an IOC container to create the destination object)
.UseValue to define a specific value for a field when mapping.

If there's something specific you're looking for, just ask! :)

---
Patrick Steele
http://weblogs.asp.net/psteele


On Tue, Jul 3, 2012 at 4:10 PM, Robert Gibbens <robgi...@gmail.com> wrote:
> I notice that Map() takes a IMappingOperationOptions and an
> Action<IMappingOperationOptions>. Is there ANY documentation or sample usage
> of this anywhere?
>
> --
> You received this message because you are subscribed to the Google Groups
> "AutoMapper-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/automapper-users/-/WWVFnn6OuEMJ.
> To post to this group, send email to automapp...@googlegroups.com.
> To unsubscribe from this group, send email to
> automapper-use...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/automapper-users?hl=en.

Jimmy Bogard

unread,
Jul 3, 2012, 11:03:48 PM7/3/12
to automapp...@googlegroups.com
That one is fairly new - added to support basically contextual mapping operations.

The idea is - create mapping extensions that need context. Things like custom value resolvers, formatters and type converters.

Next, you'll use the mapping options to pass in basically a callback to provide those instances at the time of mapping.

The thing to be used to provide those items is *most likely* a nested container. It's what we mostly use, especially in MVVM cases, where lots of places have contextual injection of instances/dependencies/values. See this blog post for more:


Which I should put on the wiki, for sure.

Make sense?

Rex Henderson

unread,
Sep 5, 2022, 8:10:26 AM9/5/22
to AutoMapper-users
It is now 2022 and there is still no really good examples or documentation exploring IMappingOperationOptions.

Jimmy Bogard

unread,
Sep 5, 2022, 10:05:28 AM9/5/22
to automapp...@googlegroups.com
It’s 2022 and no one has paid me to write the docs. Sorry, this is a free project and we all only have so much time.

On Sep 5, 2022, at 7:10 AM, Rex Henderson <r...@addmembers.com> wrote:

It is now 2022 and there is still no really good examples or documentation exploring IMappingOperationOptions.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automapper-users/b0d9f385-175c-4055-bd76-c7d28a6e8be7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages