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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:43:17+00:00 2026-05-28T06:43:17+00:00

Either I’m not, or it isn’t working… I have a single Source class that

  • 0

Either I’m not, or it isn’t working… I have a single Source class that I want to map to multiple views that inherit from each other.

Basically the base class is the Detail, and the child class is Edit or Update which use all the same data as Detail, plus a couple other fields to manage their own lists or whatever.

Here are the maps I’m using:

Mapper.CreateMap<Ticket, Detail>()
                .Include<Ticket, Update>()
                .Include<Ticket, Edit>()
                .ForMember(dest => dest.Priority, opt => opt.MapFrom(src => src.Priority.Code))
                .ForMember(dest => dest.TicketID, opt => opt.MapFrom(src => src.ID))
                .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.StatusCode))
                .ForMember(dest => dest.Category, opt => opt.MapFrom(src => src.ProblemCategoryCode))
                .ForMember(dest => dest.crmBusCode, opt => opt.MapFrom(src => src.Company.crmBusCode))
                .ForMember(dest => dest.TeamMembers, opt => opt.MapFrom(src => src.Schedules.Where(s => s.CompleteTime == null)));

            Mapper.CreateMap<Ticket, Update>()
                .ForMember(m => m.Schedules, opt => opt.MapFrom(t => t.Schedules.Where(s => s.EmployeeID == Util.CurrentUserID() && s.CompleteTime == null)));

            Mapper.CreateMap<Ticket, Edit>();

Then if I Mapper.Map(ticket) any of the properties that use MapFrom don’t get evaluated, they just end up with the values they’d have had if there was no set mapping.

So what’s wrong here?

  • 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-05-28T06:43:17+00:00Added an answer on May 28, 2026 at 6:43 am

    As an alternative solution if you don’t want to call Mapper.Map two times. You can move the common mappings of Detail into an extension method:

    public static class MappingExtensions
    {
        public static IMappingExpression<Ticket, TDest> MapDetailProperties<TDest>(
             this IMappingExpression<Ticket, TDest> mapBase) where TDest : Detail
        {
            return mapBase
                .ForMember(dest => dest.Priority, 
                    opt => opt.MapFrom(src => src.Priority.Code))
                 ///....
                .ForMember(dest => dest.TeamMembers, 
                   opt => opt.MapFrom(src => src
                       .Schedules.Where(s => s.CompleteTime == null)));
        }
    }
    

    And then use that extension method when registering the Ticket -> Update and Ticket -> Edit mappers:

    Mapper.CreateMap<Ticket, Update>()
        .MapDetailProperties()
        .ForMember(m => m.Schedules, opt => opt.MapFrom(t => t.Schedules
            .Where(s => s.EmployeeID == Util.CurrentUserID() && 
                s.CompleteTime == null)));
    
    Mapper.CreateMap<Ticket, Edit>()
        .MapDetailProperties();
    

    Then you can use Map normally:

    Ticket ticket = new Ticket();    
    var edit = Mapper.Map<Ticket, Edit>(ticket);
    var update = Mapper.Map<Ticket, Update>(ticket); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Either I'm very tired or something weird is happening that I'm not aware of,
Either my debugger is broken or there's something fundamental that I am not understanding.
Either I missed some backlash or backlashing does not seem to work with too
I am looking for either a FireFox extension, or a similar program, that allows
Since I dont have either of these devices handy to test, which method would
I want to match either @ or 'at' in a regex. Can someone help?
I may have either misunderstood how to use the ON DUPLICATE KEY syntax, alternatively
Either I have misunderstood the jQuery docs for .attr() , or I'm making a
Either v3.5 or v4.0...it seems that there is either an x86 version or x64
I want either remove or reset a style applied on a particular DOM node

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.