This is my Model
public class ContactsModel
{
public int? ContactID { get; set; }
public string ContactName { get; set; }
public string EMailID { get; set; }
public int? CountryID { get; set; }
public int? StateID { get; set; }
public long? ContactNumber { get; set; }
}
This is my Interface:
public interface IContactsRepository
{
IEnumerable<ContactsModel> GetAllContactDetails();
}
This is my RepositoryClass
public class ContactsRepository:IContactsRepository
{
private List<ContactsModel> contacts = new List<ContactsModel>();
private int _nextId = 1;
DGKumarEntities objEntity = new DGKumarEntities();
public ContactsRepository()
{
}
public IEnumerable<ContactsModel> GetAllContactDetails()
{
var contactDet = (from det in objEntity.tblContactDetails
select new ContactsModel
{
ContactID = det.ContactID,
ContactName = det.ContactName,
EMailID = det.EMailID,
CountryID = det.CountryID,
StateID = det.StateID,
ContactNumber = det.ContactNumber
});
return contactDet;
}
}
This is my Controller
private readonly IContactsRepository objIContactRepository = new ContactsRepository();
public ActionResult Index()
{
var contactDetailsResult = objIContactRepository.GetAllContactDetails();
return View(contactDetailsResult);
}
This is my My
@model MyContactsRepositoryPattern.Models.ContactsModel
when i tried to create the strongly Typed view it will not display data and this error is displaying.
"The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MyContactsRepositoryPattern.Models.ContactsModel]', but this dictionary requires a model item of type 'MyContactsRepositoryPattern.Models.ContactsModel'."
So could you please suggest me how can i resolve this and which one do i have to select do display data in strongly typed view from dropdownlist of model List