Open npatersontemenos opened 2 weeks ago
public class MapsterConfiguration : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.ForType<Timestamp, DateTime>().MapWith(d => d.ToDateTime());
config.ForType<DateTime, Timestamp>().MapWith(d => Timestamp.FromDateTime(d));
}
}
@stagep Many thanks!
Using GRPC, the proto class that maps to my POCO has one field of type google.protobuf.Timestamp, whereas, it is a datetime field in my poco. The error says "source=Google.Protobuf.WellKnownTypes.Timestamp destination=System.DateTime" and goes onto say: "Cannot convert immutable type, please consider using 'MapWith' method to create mapping". I assume this means in the configure RegisterMappings method? Can anyone steer me in the right direction to resolve this please? My code is similar to:
TypeAdapterConfig<W1, W2>.NewConfig() .Map(dest => dest.dt, src => src.Dt1)