❔ Query won't filter
I am trying to filter by one of these two search options, they both show up properly in the network but nothing displays when I run the filter functions. Anyone see anything wrong?
public List<RollingStockList> FindRollingStocksByPartialReportingMark(string partialReportingMark)
{
Console.WriteLine($"RollingStockServices: FindByPartialName(); partialName= {partialReportingMark}");
var info =
Context.RollingStocks
.Where(x => x.ReportingMark.Contains(partialReportingMark))
.Select(x => new RollingStockList
{
ReportingMark = x.ReportingMark,
Owner = x.Owner,
LightWeight = x.LightWeight,
LoadLimit = x.LoadLimit,
RailCarType = x.RailCarType.Name,
YearBuilt = x.YearBuilt,
InService = x.InService,
Notes = x.Notes
})
.OrderBy(x => x.ReportingMark);
return info.ToList();
}
public List<RollingStockList> FindRollingStocksByPartialReportingMark(string partialReportingMark)
{
Console.WriteLine($"RollingStockServices: FindByPartialName(); partialName= {partialReportingMark}");
var info =
Context.RollingStocks
.Where(x => x.ReportingMark.Contains(partialReportingMark))
.Select(x => new RollingStockList
{
ReportingMark = x.ReportingMark,
Owner = x.Owner,
LightWeight = x.LightWeight,
LoadLimit = x.LoadLimit,
RailCarType = x.RailCarType.Name,
YearBuilt = x.YearBuilt,
InService = x.InService,
Notes = x.Notes
})
.OrderBy(x => x.ReportingMark);
return info.ToList();
}
2 Replies
private void GetRollingStock(string filterType)
{
try
{
Console.WriteLine($"QueryCrudModel: GetProducts:filtertype= {filterType}");
if(filterType == "PartialString")
SearchedRollingStock = RollingStockServices.FindRollingStocksByPartialReportingMark(PartialReportingMark);
else if(filterType == "DropDown")
SearchedRollingStock = RollingStockServices.FindRollingStocksByRailCarType(SelectedRailCarTypeId);
}
catch (Exception ex)
{
ErrorMessage = GetInnerException(ex);
}
}
private void GetRollingStock(string filterType)
{
try
{
Console.WriteLine($"QueryCrudModel: GetProducts:filtertype= {filterType}");
if(filterType == "PartialString")
SearchedRollingStock = RollingStockServices.FindRollingStocksByPartialReportingMark(PartialReportingMark);
else if(filterType == "DropDown")
SearchedRollingStock = RollingStockServices.FindRollingStocksByRailCarType(SelectedRailCarTypeId);
}
catch (Exception ex)
{
ErrorMessage = GetInnerException(ex);
}
}
<input type="hidden" name="FilterType" value="@Model.FilterType">
</div>
@if(Model.SearchedRollingStock != null)
{
<div id="table_box_bootstrap">
<table class="table table-hover">
<thead>
<tr>
<th>Reporting Mark</th>
<th>Owner</th>
<th>RailCarType</th>
<th>InService</th>
</tr>
</thead>
<tbody>
@if(Model.SearchedRollingStock.Count == 0)
{
<tr><td colspan="6"><i>There is no RollingStock available.</i></td></tr>
}
@foreach(var item in Model.SearchedRollingStock)
{
<tr>
<td>
<button type="submit" class="btn btn-dark"
name="RollingStock.ReportingMark " value="@item.ReportingMark">
Edit
</button>
</td>
<td>@item.ReportingMark</td>
<td>@item.Owner</td>
<td>@item.RailCarType</td>
<td>@item.InService</td>
<td>
<input type="checkbox" disabled checked="@item.InService">
</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
<input type="hidden" name="FilterType" value="@Model.FilterType">
</div>
@if(Model.SearchedRollingStock != null)
{
<div id="table_box_bootstrap">
<table class="table table-hover">
<thead>
<tr>
<th>Reporting Mark</th>
<th>Owner</th>
<th>RailCarType</th>
<th>InService</th>
</tr>
</thead>
<tbody>
@if(Model.SearchedRollingStock.Count == 0)
{
<tr><td colspan="6"><i>There is no RollingStock available.</i></td></tr>
}
@foreach(var item in Model.SearchedRollingStock)
{
<tr>
<td>
<button type="submit" class="btn btn-dark"
name="RollingStock.ReportingMark " value="@item.ReportingMark">
Edit
</button>
</td>
<td>@item.ReportingMark</td>
<td>@item.Owner</td>
<td>@item.RailCarType</td>
<td>@item.InService</td>
<td>
<input type="checkbox" disabled checked="@item.InService">
</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.