TinyMapper / TinyMapper

A quick object-object mapper for .NET
http://tinymapper.net
MIT License
691 stars 112 forks source link

Nulll checking for navigation property in Bind expression #91

Closed yeasin90 closed 1 year ago

yeasin90 commented 2 years ago

Is there any way to add null-checking in config.Bind?

public class CommonClassSource
{
public int Id {get;set;}
}

public class CommonClassDestination
{
public int Id {get;set;}
}

public class SourceClass
{
public CommonClassSource CommonSource {get;set;}
}

public class DestinationClass
{
public CommonClassDestination CommonDestination {get;set;}
}

For example: here, check if source.CommonSource is null

TinyMapper.Bind<SourceClass, DestinationClass>(config => {
config.Bind(source => source.CommonSource.Id,
                  target => target.CommonDestination.Id));
});
GSerjo commented 1 year ago

Hey @yeasin90, no, there's no this ability. it's just a mapping between fields