KOMARA
KOMARA

Reputation: 51

problem with automapper I can't access the properties c#

I have an error by what I want to access the properties of ViewModel

my problem is here

this is my model

enter image description here

this is my ViewModel

    public class ViewModelDemande
{
    public SeDemande seDemandes { get; set; }

    public SeTypeProduit SeTypeProduit { get; set; }
    public  List<SeCritereTest> SeCritereTest { get; set; }
    public SePartenir sePartenirs { get; set; }
    public SeTraitementDemande seTraitementDemandes { get; set; }
    public SeInformationClient SeInformationClient { get; set; }
    public SeClient SeInclient { get; set; }
    public SeAssistantClient assitantclient { get; set; }

    public  SePrestation prestation { get; set; }

    public SeDemandeTypeProduit demandeTypeProduit { get; set; }

    public bool dollar_sgd { get { return seDemandes.DemDollarSgd == true; } set { seDemandes.DemDollarSgd = value; } }
}

my problem is here

public class MappingProfile : Profile
{
    public MappingProfile()
    {
        CreateMap<SeDemande,ViewModelDemande.SeDemande>(); // Mappage de l'objet Developer à l'objet DeveloperDTO
    }
}

Upvotes: 0

Views: 84

Answers (2)

Nemanja Todorovic
Nemanja Todorovic

Reputation: 2800

I would recommend doing a mapping between types:

public class MappingProfile : Profile
    {
        public MappingProfile()
        {
            CreateMap<SeDemande, ViewModelDemeande>()
                .ForMember(dest => dest.seDemande, opt => opt.MapFrom(src => src));
        }
    }

Upvotes: 2

John
John

Reputation: 1285

It looks like the property should be:

ViewModelDemande.seDemande

Notice the lowercase "s".

Upvotes: 1

Related Questions