Cheers,
Sunny
> --
> 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/-/vHEXGAvIjooJ.
> 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.
--
Svetoslav Milenov (Sunny)
Artificial Intelligence is no match for natural stupidity.
.ForMember(opt => {
opt.Condition(s=> s != null && s.Count>4);
opt.MapFrom(s=>s.Items.Select(x=>x>10));
});
Cheers,
Sunny
> --
> 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/-/BrjEN81qfVIJ.
class MapTo
{
public string MappedData { get; set; }
}
And use:
.ForMember(d => d.MappedData, opt => opt.MapFrom(s => SafeMap(s)));
private static string SafeMap(MapFrom mapFrom)
{
return mapFrom != null && mapFrom.Data != null
? mapFrom.Data.First()
: null;
}
Cheers
> --
> 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/-/uBoSrVpH3CkJ.
Thanks
private MyClass GetFromString(string key)...(does basic lookup in dict lets say)
....
.ForMemeber(d=>d.MyClassProp, opt=>opt.MapFrom(s=>GetFromString(s.MyClassKey)))
and
.ResolveUsing(d=>d.MyClassProp,
opt=>opt.MapFrom(s=>GetFromString(s.MyClassKey)))
I know that the right thing to do is actually to set mapper <string,
MyClass>, but for various reasons I can not do that. So it leaves me
with the option of using one of the 2 choices above.
So, what would be the difference? Why should I prefer one or the other?
Thanks
And the second example I provide was wrong, I meant compare
.ForMemeber(d=>d.MyClassProp, opt=>opt.MapFrom(s=>GetFromString(s.MyClassKey)))
and
.ForMemeber(d=>d.MyClassProp,
opt=>opt.ResolveUsing(s=>GetFromString(s.MyClassKey)))
--
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/-/vHEXGAvIjooJ.