In my ASP.NET MVC 2 (RC) project - I use AutoMapper to map between the Linq to Sql class (Media) and the view model (MediaVM). The view model has a SelectList property for the drop-down list. I have a custom value converter to populate the elements of the SelectList property from db, but I'm wondering if there is a way to pass a pair of values ββfrom the original model to resolver (using the ConstructedBy method?) Q a) define the selected element and b) filter the elements from db. The source object is passed to the custom resolver, but the recognizer is used in several different view models with different types of source objects, so itβs more likely to determine where to get the values ββfrom my mapping configuration. Here is my model:
public class MediaVM { public bool Active { get; set; } public string Name { get; set; } [UIHint("DropDownList")] [DisplayName("Users")] public SelectList slUsers { get; private set; } }
Automata mapping configuration:
Mapper.CreateMap<Media, MediaVM>() .ForMember(dest => dest.slUsers, opt => opt.ResolveUsing<UsersSelectListResolver>());
It would be nice to be able to do something similar in the .ForMember conversion clause:
.ConstructedBy(src => new UsersSelectListResolver(src.UserID, src.FilterVal))
Is there any way to do this?
Bryan
source share