-
Notifications
You must be signed in to change notification settings - Fork 36
Create map for member: ignore
Bert Loedeman edited this page Aug 26, 2015
·
2 revisions
It is possible to ignore destination properties while mapping using the createMap.forMember.ignore function.
// arrange
var objA = { prop: 1 };
var fromKey = '{76D26B33-888A-4DF7-ABDA-E5B99E944272}';
var toKey = '{18192391-85FF-4729-9A08-5954FCFE3954}';
automapper
.createMap(fromKey, toKey)
.forMember('prop', (opts: AutoMapperJs.IMemberConfigurationOptions) => { opts.ignore(); });
// act
var objB = automapper.map(fromKey, toKey, objA);
// assert
expect(objB.hasOwnProperty('prop')).not.toBeTruthy();
Tip: it is also possible to get ignorance to work based on a condition.
AutoMapperTS is Copyright © 2015 Bert Loedeman and other contributors under the MIT license.
Getting started
Mapping performance
Initialization (initialize)
Mapping configuration (createMap)
- forMember
- forSourceMember
- condition
- forAllMembers
- ignoreAllNonExisting
- convertToType
- convertUsing
- withProfile
Validation (assertConfigurationIsValid)
Mapping (map)
Currying
Custom type converters
Profiles
Chaining
Naming conventions
Asynchronous mapping
Flattening and nesting