-
Notifications
You must be signed in to change notification settings - Fork 36
Create map for source member: ignore
Bert Loedeman edited this page Sep 16, 2015
·
3 revisions
It is possible to ignore source properties while mapping using the createMap.forSourceMember.ignore function.
// arrange
var objA = { prop1: 'From A', prop2: 'From A too' };
var fromKey = '{AD88481E-597B-4C1B-967B-3D700B8BAB0F}';
var toKey = '{2A6714C4-784E-47D3-BBF4-6205834EC8D5}';
automapper
.createMap(fromKey, toKey)
.forSourceMember('prop1', (opts: AutoMapperJs.ISourceMemberConfigurationOptions) => { opts.ignore(); });
// act
var objB = automapper.map(fromKey, toKey, objA);
// assert
expect(objB).toEqualData({ prop2: 'From A too' });Tip: it is also possible to get ignorance to work based on a condition (it's not a source member option, though).
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