Description:An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.
Controller Code:
public ActionResult Index()
{
Mapper.CreateMap<Student, Student1>();
var dbContext = new WorkTraningEntities();
StudentCRUD stud = new StudentCRUD();
var students = stud.SelectAll();
List<Student1> stud1 = Mapper.Map<List<Student1>>(students);
return View(stud1);
None
0 Points
40 Posts
hi experts..im trying to AutoMapper with Store procedure getting an error..pls help
May 03, 2016 05:10 AM|Sunil3|LINK
Error:
Missing type map configuration or unsupported mapping.
Mapping types:
sp_selectall_Result -> Student1
MvcCRUD6.Models.sp_selectall_Result -> MvcCRUD6.Models.Student1
Destination path:
List`1[0]
Source value:
MvcCRUD6.Models.sp_selectall_Result
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.
Controller Code:
public ActionResult Index()
{
Mapper.CreateMap<Student, Student1>();
var dbContext = new WorkTraningEntities();
StudentCRUD stud = new StudentCRUD();
var students = stud.SelectAll();
List<Student1> stud1 = Mapper.Map<List<Student1>>(students);
return View(stud1);
}
Index View:
@model IEnumerable<MvcCRUD6.Models.Student1>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.First_Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Middle_Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Last_Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Contact_No)
</th>
<th>
@Html.DisplayNameFor(model => model.Email_ID)
</th>
<th>
@Html.DisplayNameFor(model => model.Temp_Address)
</th>
<th>
@Html.DisplayNameFor(model => model.Permanant_Address)
</th>
<th>
@Html.DisplayNameFor(model => model.Country.CountryName)
</th>
<th>
@Html.DisplayNameFor(model => model.State.StateName)
</th>
<th>
@Html.DisplayNameFor(model => model.City.CityName)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.First_Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Middle_Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Last_Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Contact_No)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email_ID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Temp_Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.Permanant_Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.Country.CountryName)
</td>
<td>
@Html.DisplayFor(modelItem => item.State.StateName)
</td>
<td>
@Html.DisplayFor(modelItem => item.City.CityName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.StudentID }) |
@Html.ActionLink("Details", "Details", new { id=item.StudentID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.StudentID })
</td>
</tr>
}
</table>
All-Star
194032 Points
28035 Posts
Moderator
Re: hi experts..im trying to AutoMapper with Store procedure getting an error..pls help
May 12, 2016 09:30 AM|Mikesdotnetting|LINK
What is the return type of your StudentCRUD.SelectAll method?