I am a newbie to C# and have inherited a web app that I am now solely responsible for fixing and enhancing. I just created a Controller and a view via the VS wizard "MVC 5 Controller with views, using Entity Framework". I am using the default code that VS generated.
I also noticed that the record still comes up even if the ID is the same one as in the SQL View.
Any help would be greatly appreciated!
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.JudgmentID)
</td>
<td>
@Html.DisplayFor(modelItem => item.LoanID)
</td>
<td>
@Html.DisplayFor(modelItem => item.JudgmentAmount)
</td>
<td>
@Html.DisplayFor(modelItem => item.JudgmentDate)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
1050001010 1000.00 7/5/2016 12:00:00 AM Edit | Details | Delete
1050001010 1000.00 7/5/2016 12:00:00 AM Edit | Details | Delete
The second record should be different.
I get this error in a log.
SOURCE:System.Core TRACE: at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.b__2[TResult](IEnumerable1 sequence) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
What I have tried:
I have tried to start over and build everything a second time.
I have ran a debug session and in the controller, it is duplicated so index.chtml is only showing what the controller is getting.