Skip to content

Does mapping for primitive type to primitive type works? #114

@fugaku

Description

@fugaku

So, does mapping for primitive type to primitive type works?
I need to map a null string to a string empty one.

Maybe something like below ?

Mapper.RegisterCustom<string, string>(src => 
{
 if (src == null) {
  return string.Empty;
 } else {
  return src;
 }
}
Mapper.Register<Foo, Bar>();

where Foo has a property
public string Property1 {get;set;}

and Bar has a property also
public string Property2 {get;set;}

So when I map using
var barObject = Mapper.Map<Foo, Bar>(fooObject);

Do I get the "Property2" property to be set as string empty ?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions