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 8856449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:21:33+00:00 2026-06-14T14:21:33+00:00

I am using Automapper to map EF objects to DTOs; many of the objects

  • 0

I am using Automapper to map EF objects to DTOs; many of the objects are in many-to-many arrangements. For example:

committee (table) 1 =< m  committeemember (table)  m >= 1 person (table)

That might map to:

public class CommitteeViewModel
{
    public int idCommittee { get; set; }
    public IEnumerable<CommitteeMemberViewModel> CommitteeMembers { get; set; }
}

public class CommitteeMemberViewModel
{
    public int idCommittee { get; set; }
    public int idCommitteeMember { get; set; }
    public PersonViewModel Members { get; set; }
}

And there are Automapper maps for <committee, CommitteeViewModel>, <committeemember, CommitteeMemberViewModel>, and <person, PersonViewModel>.

All is well when I want to return a single committee and its members.

BUT, when I want a list of committees without members, is there a way to ask Automapper to ignore certain properties, just for that call? Sort of like:

var committeeList = Automapper.Mapper.Map
    <List<committee>, List<CommitteeViewModel>>(committees)
   .Ignore("CommitteeMembers");

Of course, I can create new DTOs that omit these properties and map to those, but since I essentially want everything but one property, I thought there might be a better way, like creating a different map — but I’m not managing to find it.

Thanks,

g.

  • 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-14T14:21:34+00:00Added an answer on June 14, 2026 at 2:21 pm

    You can achieve desired result this way: create new mapping (i.e. overwrite existing one), map your source entities, and override mapping back:

    Mapper.CreateMap<committee, CommitteeViewModel>()
          .ForMember(c => c.CommitteeMembers, o => o.Ignore());
    
    var committeeList = Mapper
          .Map<List<committee>, List<CommitteeViewModel>>(committees);
    
    Mapper.CreateMap<committee, CommitteeViewModel>();
    

    But I think it’s better to keep things consistent. If I do mapping from committee to CommitteeViewModel I expect it will produce same result each time. So, it’s better to create new view model for ‘light’ version of mapping.

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

Sidebar

Related Questions

I am using AutoMapper to map objects from a legacy database to a new
I have this interface for using AutoMapper: public interface IMapper { object Map(object source,
I am using Automapper in my project to map business entities to DTO. public
I am using AutoMapper.org to map my DTO objects to Model objects in MVC4.
I am using AutoMapper in my ASP.NET MVC website to map my database objects
I am using automapper (successfully up to a point) to perform a polymorphic map
I'm using AutoMapper to map between a Linq Domain object and a ViewModel to
Lets say that I have a list of objects like so: public class FlatModel
I'm using AutoMapper to mapping my Entity Framework POCO objects and ViewModels. Question 1:
In my ASP.NET MVC 2 (RC) project - I'm using AutoMapper to map between

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.