I'd like to be able to pass multiple objects to Automapper via the Options dictionary, but the dictionary itself is read only.
E.g. the examples I've found show adding one item like this:
Mapper.Map<Source, Dest>(src, opt => opt.Items["Foo"] = "Bar");
But I'd like to do something more like this:
var mappingOptions = new Dictionary<string, object>();
mappingOptions["foo"] = "foo";
mappingOptions["bar"] = "bar";
var model = _mapper.Map<ThingModel>(realthing,
opt => opt.Items = mappingOptions // readonly, can't be assigned
);
Is adding more than one item possible, maybe just inside the LINQ?
Do you mean like this?
Mapper.Map<Source, Dest>(src, opt =>
{
opt.Items["foo"] = "foo";
opt.Items["bar"] = "bar";
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With