I have a Model that named word.
this is my word model
public class Word : BaseFieldsTables
{
int ID { get; set; }
string Name { get; set; }
Guid UniqID { get; set; }
DateTime CreatedDate { get; set; }
byte[] RowVersion { set; get; }
public string Text { get; set; }
public virtual Category Category { get; set; }
public int CategoryID { get; set; }
public virtual Language Language { get; set; }
public int LanguageID { get; set; }
public virtual ICollection<Picture> Pictures { get; set; }
[InverseProperty("MainWord")]
public virtual ICollection<RelationshipBetweenWords> MainWords { get; set; }
[InverseProperty("RelatedWord")]
public virtual ICollection<RelationshipBetweenWords> RelatedWords { get; set; }
}
word has a category and language and…
for example this is my language model
public class Language : BaseFieldsTables
{
int ID { get; set; }
string Name { get; set; }
Guid UniqID { get; set; }
DateTime CreatedDate { get; set; }
byte[] RowVersion { set; get; }
public virtual ICollection<Word> Words { get; set; }
}
i have word word viewmodel like this
public class WordViewModel
public string Name { get; set; }
public IList<SelectListItem> Categories { set; get; }
[HiddenInput(DisplayValue = false)]
public int SelectedCategoryID { set; get; }
public IList<SelectListItem> Languages { set; get; }
[HiddenInput(DisplayValue = false)]
public int SelectedLanguageID { set; get; }
}
and this my controller
public ActionResult Index(
{
IList<Word> list = _wordService.GetAll();
}
i want to get all word and map(auotomapper) to my WordViewModel with languagename and category name and return in my view please help me if i have to change my wordviewmodel or… and how to map.tnx
oh i found it