i need show all category in view . i used this code for show all :
Category = Tabel name of Database
public List<Category> GetAllCategory()
{
return _repository.GetAll();
}
/****************************************/
public ActionResult ListCategory()
{
return View(_CategoryService.GetAllCategory());
}
/*****************************************/
i create model CategoryModel
.
public class CategoryModel
{
[Display(Name ="کد دسته")]
public int CatID { get; set; }
[Display(Name = " نام دسته")]
public string CategoryName { get; set; }
[Display(Name = " سر دسته")]
public int ParentID { get; set; }
}
/**********************************/
and in view i use this :
@model IEnumerable<Amene.Models.CategoryModel>
but it show me this error :
The model item passed into the dictionary is of type 'System.Collections.Generic.List
1[DA.Data.DB.Category]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1[Amene.Models.CategoryModel]'.
o know i must user table name in view Category
but i need use CategoryModel
.
how can i do this ?