我有一个控制器,其中包含来自数据库的 3 个数据上下文,需要在 3 个不同表的同一视图中显示它们。我需要使用 PagedList 因为我在这个表中收到了富有表现力的卷数据。但是当更改页表时,其他表也会更改。我已经尝试为它们中的每一个添加变量page和pageNumberViewBag Data,但它不起作用。视图模型:public sealed class FileViewModel{ private readonly IFileDataContext _context; static FileViewModel() { } private FileViewModel() { _context = new FileDataContext(); } private static readonly FileViewModel fileViewModel = new FileViewModel(); public static FileViewModel Instance { get { return fileViewModel; } } public FileData FileDados { get; set; } public IPagedList<FileDocs> FileDocs { get; set; } public IEnumerable<FileDocs> ServicoDocs { get; set; } public IPagedList<FileRequisition> Requisicoes { get; set; } public IPagedList<FileService> Servicos { get; set; } public IEnumerable<FileService> ServicosAgrupado { get; set; }}控制器:public ActionResult GetFile(int fileCodigo, int? page){ //fileCodigo = 190562; //Variaveis int pageSize = 5; int pageNumber = (page ?? 1); ViewBag.FileCodigo = fileCodigo; var docsGeraisFile = Directory.EnumerateFiles(directoryPath, "*", SearchOption.AllDirectories).ToList(); //GetFile FileViewModel.Instance.FileDados = _context.GetFileByFileCode(fileCodigo).FirstOrDefault(); //GetFileDocs FileViewModel.Instance.FileDocs = _context.GetFileIntraByFile(fileCodigo) .Where(fd => fd.NivelArquivo == fileCodigo.ToString()).ToPagedList(pageNumber, pageSize); //GetServicos FileViewModel.Instance.Servicos = _context.GetServicosByFile(fileCodigo).DistinctBy(s => s.CodServico).ToPagedList(pageNumber, pageSize); //GetServiceDocs var fs = _context.GetServicosByFile(fileCodigo) .Select(s => s.CodServico).ToList(); FileViewModel.Instance.ServicoDocs = _context.GetFileIntraByFile(fileCodigo) .Where(ds => ds.NivelArquivo == fs.FirstOrDefault()).ToList();}
- 1 回答
- 0 关注
- 53 浏览
添加回答
举报
0/150
提交
取消