Sidereus
Sidereus

Reputation: 220

Is mapster able to map A->C if it can map A->B and B->C?

I have three classes

public class A
{
    public string Value1 { get; set; }
    public string Value2 { get; set; }
}

public class B
{
    public int Value1 { get; set; }
    public string Value2 { get; set; }
}

public class C
{
    public int Value1 { get; set; }
    public int Value2 { get; set; }
}

I want to be able to Map

A->B

B->C

A->C

so I have two configs

public void AddMappings()
{
    TypeAdapterConfig<A,B>
      .ForType()
      .Map(dest => dest.Value1, src => ConvertToInt(src.Value1));
    TypeAdapterConfig<B,C>
      .ForType()
      .Map(dest => dest.Value2, src => ConvertToInt(src.Value2));
}

Is there a way to configure mapster so it knows that it can use A->B + B->C to map A->C? This would help because otherwise I need to make another TypeAdapterConfig<A, C> where I Map both Value1 and Value2.

Upvotes: 0

Views: 57

Answers (0)

Related Questions