我有以下操作方法:-
public ActionResult Index(string searchTerm=null, int page = 1)
{
var racks = repository.AllFindRacks(searchTerm).OrderBy(a=>a.Technology.Tag).ToPagedList(page, 5) ;
if (Request.IsAjaxRequest())
{
return PartialView("_RackTable", racks);
}
return View(racks);
}
它调用以下存储库方法:-
public RackJoinList AllFindRacks(string q)
{
RackJoinList rjlist = new RackJoinList();
var racks = from rack in tms.TMSRacks.Where(a => a.Technology.Tag.ToUpper().StartsWith(q.ToUpper()) || (q == null))
select rack;
rjlist.Racks = racks.ToList();
var resources = from resource in entities.Resources
join c in rjlist.Racks
on resource.RESOURCEID equals c.Technology.IT360ID
select resource;
rjlist.Resources = resources;
return rjlist;
}
并且RackJoinList
视图模型是:-
public class RackJoinList
{
public IEnumerable<TMSRack> Racks { get; set; }
public IEnumerable<Resource> Resources { get; set; }
}
但是由于存储库方法返回单个对象,我无法对其应用 orderby 和分页。任何人都可以就如何解决这个问题提出建议吗?