I want to search and for records in the DB and display. But the search is not working i am getting an error like Error = The function evaluation requires all threads to run. The dbcontext not returning any rows.
What I have tried:
[HttpPost]
public ActionResult Search( string Search)
{
var emp = from m in db.Emps
select m;
if (emp != null)
{
var ttt = db.Emps.Where(s => s.Name.Contains(Search));
}
else
{
ModelState.AddModelError("Name"," No records found");
}
return View(emp);
}
@using (Html.BeginForm("Search", "Emps", FormMethod.Post))
{
<div class="container form-group">
<input class="form-control" type="text" id="Mail" name="Search">
</div>
@*@Html.TextBox("SearchText")*@
<div class="form-group">
<input type="submit" value="Search" id="searching" class="btn btn-default mysquare" />
</div>
}
@if (Model != null)
{
foreach (var person in Model)
{
<tr>
<td>
@Html.DisplayFor(modelitem => person.ID)
</td>
</tr>
<tr>
<td>
@Html.DisplayFor(modelitem => person.Name)
</td>
</tr>
<tr>
<td>
@Html.DisplayFor(modelitem => person.City)
</td>
</tr>
<tr>
<td>
@Html.DisplayFor(modelitem => person.Designation)
</td>
</tr>
<tr>
<td>
@Html.DisplayFor(modelitem => person.Country)
</td>
</tr>
<tr>
<td>
@Html.DisplayFor(modelitem => person.Mail)
</td>
</tr>
}
}