0
I need to make a select
with two tables and play the result for a PagedList
. But when I query, returns the error:
Cannot implicitly Convert type 'Pagedlist.Ipagedlist' to 'Pagedlist.Ipagedlist<>'. An Explicit Conversion exists (are you Missing a cast?) C: IIS System Controllers Titcontroller.Cs
But when I remove the Join
, he does not return the error.
How to correct this error, and I could see this other table in my view?
Follow the code below:
public ActionResult ConTitulos(int? Pagina, string Pesquisa, decimal? NProtocolo, For model)
{
var entities = new Model();
if (!string.IsNullOrEmpty(Pesquisa) || Pagina.HasValue)
{
var results = entities.For
.Join(entities.Dev,
t => t.For_Dev_ID,
h => h.Dev_ID,
(t, h) => new
{
t.For_Nome,
h.Dev_Nome
})
.Where(b => b.Protocolo == NProtocolo).AsEnumerable();
var pageIndex = Pagina ?? 1;
model.ProcuraResultados = results.ToPagedList(pageIndex, RecordsPerPage);
}
if (model.ProcuraResultados != null && model.ProcuraResultados.Count == 1)
{
foreach (var item in model.ProcuraResultados)
{
return RedirectToAction("Devedores", new { id = item.For_ID });
}
}
return View(model);
}
View
@model Sistema.Models.for
@{
ViewBag.Title = "Consulta de Devedores";
}
@using PagedList.Mvc;
<h2>Consulta de Devedores</h2>
<div id="page-wrapper">
<div class="content-wrapper">
<div class="container-fluid">
@using (Html.BeginForm("ConTitulos", "Devedores", FormMethod.Get))
{
<table width="100%">
<tr>
<td class="tblNormal">Nº do Protocolo</td>
</tr>
<tr>
<td class="tblNormal">
<input type="text" name="NProtocolo" onkeypress="FiltraTecla(event);" size="10" maxlength="10" value="">
@*@Html.EditorFor(model => model.TIT_PRT_CRT, new { htmlAttributes = new { @class = "form-control", name= "NProtocolo",size = "10", maxlength = "10", value = "" } })*@
</td>
</tr>
</table>
if (Model.ProcuraResultados != null && Model.ProcuraResultados.Count > 1)
{
<div>
<br />
<table class="table">
<tr>
<th>Devedor</th>
<th>Fornecedor</th>
</tr>
@foreach (var item in Model.ProcuraResultados)
{
<tr>
<td class="control-label">@item.Dev_nome</td>
<td class="control-label">@item.For_Nome</td>
<td>
@Html.ActionLink("Alterar", "AltDevedor", new { id = @item.DEV_ID }, null)
</td>
</tr>
}
</table>
</div>
@Html.PagedListPager(Model.ProcuraResultados, page => Url.Action("ConTitulos", new RouteValueDictionary()
{
{ "Pagina", page },
{ "Apresentante", Model.Dev_nome },
{ "Devedor", Model.For_Nome }
}),
PagedListRenderOptions.PageNumbersOnly)
}
}
</div>
</div>
</div>
Welcome Germano. You can post your
view
also?– Luídne
I put the View too!
– Germano Sampaio