Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8531557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:30:44+00:00 2026-06-11T09:30:44+00:00

I have two sub class that I need to copy a List element from

  • 0

I have two sub class that I need to copy a List element from into a master object

public Class Foo1 : Anote
{
  public bool Ison { get; set;}
  public List<Anote>Anotes { get; private set;}

  public Foo1()
  {
    this.Anotes = new List<Anote>();
  }
}

public Class Foo2 : Bnote
{
  public bool Ison { get; set;}
  public List<Bnote>Anotes { get; private set;}

  public Foo2()
  {
    this.Anotes = new List<Bnote>();
  }
}

public Class Foo3 : Cnote
{
   public bool Ison { get; set;}
   public List<Cnote>Anotes { get; private set;}
   public List<Cnote>Bnotes { get; private set; }

}

I will be retreiving data from a database and putting this data into Foo1 and Foo2. I then need
to Map the List data from Foo1 and Foo2 into the List elements in Foo3.

I have done

Foo1A foo1a = new Foo1A();
Foo2A foo2a = new Foo2A();

Mapper.CreateMap<Foo1, Foo1A>();
Mapper.CreateMap<Foo2, Foo2A>();
Mapper.Map<Foo1, Foo2A>(foo1, foo1a);
Mapper.Map<Foo2, Foo2A>(foo2, foo2a);

and this works but what I need to do is

Map the List Anotes in Foo1 to the List Anotes in Foo3
Map the List Anotes in Foo2 to the List Bnotes in Foo3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:30:46+00:00Added an answer on June 11, 2026 at 9:30 am

    You should just be able to do:

    Mapper.CreateMap<ANote, CNote>();
    
    Mapper.CreateMap<Foo1, Foo3>()
        .ForMember(dest => dest.ANotes, opt => opt.MapFrom(src => src.ANotes))
        .ForMember(dest => dest.BNotes, opt => opt.Ignore());
    
    Mapper.CreateMap<Foo2, Foo3>()
        .ForMember(dest => dest.BNotes, opt => opt.MapFrom(src => src.ANotes))
        .ForMember(dest => dest.ANotes, opt => opt.Ignore());
    
    Foo3 foo3 = new Foo3();
    
    Mapper.Map<Foo1, Foo3>(foo, foo3);
    Mapper.Map<Foo2, Foo3>(foo2, foo3);
    

    foo3.ANotes and foo3.BNotes should both have been mapped correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class Field of which there are two sub-classes AccountField and DecimalField
I have a website that is mirrored cross two sub-domains. So I have separate
I have these two modules : package G1; sub new { my $class =
i have a query that in a sub query calculates amount by dividing two
I have a query to select from another sub-query select. While the two queries
I have a class that has two method in it, one calls a class
I have an activity that populates a list and does some other things from
I've factored out common attributes from two classes into an abstract base class, however
I have a main class that has a Sub procedure with no implementation. Any
I have two classes: Superclass and derived Subclass:Superclass. I have a generic method: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.