Very strange thing happened in my project, i have a pretty simple CLR objects,
First one is the Model other is ViewModel, after i compile the project i run my WebApi ASP.NET project, with the required parameters, i can see that my Model return with data.
Once i can see the Mapper did mapping ok, and the second time it's return every thing with nulls. The problem that is not happens all the time.
Very Important: Update 14.03.2013
It's stop doing it when i recycle application,
but after a while it's start doing it again, i re-save the web.config file
then it's ok again.
Here is my Model/ViewModel:
public class Gallery : Entity
{
public override long Id { get; set; }
public virtual Settings SiteOwner { get; set; }
public virtual Category Category { get; set; }
public virtual string PageTitle { get; set; }
public virtual string TitleDescription { get; set; }
public virtual string GalleryTitle { get; set; }
public virtual IList<UIItem> GalleryItems { get; set; }
}
public class UIItem : Entity
{
public override long Id { get; set; }
public virtual Product Product { get; set; }
public virtual Gallery Gallery { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual string Price { get; set; }
public virtual string ImageUrl { get; set; }
public virtual string VideoUrl { get; set; }
public virtual string FileUrl { get; set; }
}
public class GalleryViewModel
{
public virtual string PageTitle { get; set; }
public virtual string TitleDescription { get; set; }
public virtual string GalleryTitle { get; set; }
public virtual IList<UIItemViewModel> GalleryItems { get; set; }
}
public class UIItemViewModel
{
public virtual long Id { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual string Price { get; set; }
public virtual string ImageUrl { get; set; }
public virtual string VideoUrl { get; set; }
public virtual string FileUrl { get; set; }
}
Here is the way i use it
// my apicontroller
// FindGalleryByAppIdAndCategoryId returns => Gallery
var source = _galleryRepository.FindGalleryByAppIdAndCategoryId(appId, catId);
return Mapper.DynamicMap<GalleryViewModel>(source);