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

  • Home
  • SEARCH
  • 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 554105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:40:29+00:00 2026-05-13T11:40:29+00:00

In my ASP.NET MVC 2 (RC) project – I’m using AutoMapper to map between

  • 0

In my ASP.NET MVC 2 (RC) project – I’m using AutoMapper to map between a Linq to Sql class (Media) and a view model (MediaVM). The view model has a SelectList property for a drop down in the view. I have a custom value resolver to populate the SelectList property items from the db, but am wondering if there’s a way to pass a couple values from the source model into the resolver (using ConstructedBy method?) to a) define the selected item and b) filter the items from the db. The source object gets passed into the custom resolver – but the resolver is used on several different view models with different types of source objects, so would rather define where to get the values from in my mapping config. Here is my view model:

public class MediaVM
{
    public bool Active { get; set; }
    public string Name { get; set; }

    [UIHint("DropDownList")]
    [DisplayName("Users")]
    public SelectList slUsers { get; private set; }
}        

The automapper mapping config:

    Mapper.CreateMap<Media, MediaVM>()
        .ForMember(dest => dest.slUsers, opt => opt.ResolveUsing<UsersSelectListResolver>());

It would be nice to be able to do something like this on the .ForMember mapping clause:

.ConstructedBy(src => new UsersSelectListResolver(src.UserID, src.FilterVal))

Is there a way to accomplish this?

  • 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-13T11:40:30+00:00Added an answer on May 13, 2026 at 11:40 am

    I found your posting trying to do the same thing. I decided on a simple approach and skip trying to map to my select list directly via AutoMaper. I simply return an array into my ViewModel and reference that object for my select list. The array gets mapped, select list object does not. Simple, effective. And, IMHO each is doing it’s intended task – the mapper maps, the ViewModel does the layout

    View Model code:
            [DisplayName("Criterion Type")]
            public virtual CriterionType[] CriterionTypes { get; set; }
    
            [DisplayName("Criterion Type")]
            public SelectList CriterionTypeList
            {
                get
                {
                    return new SelectList(CriterionTypes, "Id", "Key");
                }
            }  
    

    my mapper:

     Mapper.CreateMap<Criterion, CriterionForm>()
                .ForMember(dest => dest.CriterionTypeList, opt => opt.Ignore());     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using an ASP.NET MVC project and everytime I add a class to
I'm starting an ASP.NET MVC project using SubSonic 3 ActiveRecord. I added a table
In my ASP.NET MVC project, I have this code in a view: [...] <%if(item.IsActive)
Say you have an ASP.NET MVC project and are using a service layer, such
I have an existing ASP.Net MVC project that is using entities / repositories in
I am using T4MVC in our ASP.NET MVC project. I have a statement like
My ASP.NET MVC project has some chapter class and related tag class They have
I am using ASP.NET MVC project and jQuery to handle async requests. Sometimes for
I have an ASP.NET MVC project containing an AdminController class and giving me URls
I have an asp.net mvc project and reference a dll to a class library.

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.