相关疑难解决方法(0)

如何搜索来自另一个页面模型的串联名称列表?

我的项目中有多个模型,但在下面的屏幕中,大多数字段/属性都位于 SecurityLog 模型中。

下面是我显示连接的军官列表的地方。除了官员姓名之外,我的搜索和列标题排序可以正常工作。我很难合并官员姓名 b/c 列表来自另一个页面模型。

在此处输入图片说明

这是我的数据库架构和示例结果

在此处输入图片说明

我可以根据 Microsoft 的 Contoso 大学的演示来实现排序、搜索和分页。

https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/sort-filter-page?view=aspnetcore-3.1

我如何解决在我当前代码中搜索官员姓名的问题?更具体地说,对于搜索……我如何阅读(迭代)OfficerID 列表并搜索每个列表项(连接的官员列表行)的字符串值?

foreach (SecurityLog secLog in SecurityLog)
        {
            secLogCopy = secLog;

            OfficerLists = officerList.GetOfficerList(_context, secLog, rowID, OfficerIDs);
            if (!String.IsNullOrEmpty(searchString))
            {
                sort = sort.Where(s => OfficerIDs.ToString().Contains(searchString));
            }
            rowID++;
        }
Run Code Online (Sandbox Code Playgroud)

页面模型:

namespace SecurityCore.Pages.SecurityLogs
{
    public class IndexModel : PageModel
    {
        private readonly SecurityCore.Models.SecurityCoreContext _context;

        public IndexModel(SecurityCore.Models.SecurityCoreContext context)
        {
            _context = context;
        }

        public string EventDateSort { get; set; }        
        public string CurrentSort { get; set; }


        [DataType(DataType.Date)]
        public Nullable<DateTime> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core razor-pages

5
推荐指数
2
解决办法
336
查看次数

标签 统计

asp.net-core ×1

c# ×1

razor-pages ×1