1

I wanted to use Mapster to map some classes. My origin class is this:

public partial class Componente : ObservableObject
    {
        public Componente() { }

        public Componente(long paramLgId) : base()
        {
            this.Id = paramLgId;
        }



        [ObservableProperty]
        long _id;

        private readonly HashSet<PrecioHistorico> _preciosHistorico = new HashSet<PrecioHistorico>();
        public IReadOnlyCollection<PrecioHistorico> PreciosHistorico => _preciosHistorico;



        public void AddPrecioHistorico(PrecioHistorico paramPrecioHistorico)
        {
            _preciosHistorico.Add(paramPrecioHistorico);
        }

        public void RemovePrecioHistorico(PrecioHistorico paramPrecioHistorico)
        {
            _preciosHistorico.Remove(paramPrecioHistorico);
        }
    }

In which I have declare a readonly collection in which I can add and remove items with the methds.

But I am wondering if I the case I want to map from destination to this class it is possible, because only it is possible to add items with the methods.

Thanks.

Álvaro García
  • 18,114
  • 30
  • 102
  • 193

0 Answers0