无法隐式转换System.LINQ,如果您缺少转换,则存在显式转换

问题描述 投票:0回答:1

我目前正在尝试通过API搜索查询实现TypeAhead插件。下面的代码是我从一个肮脏的Mosh(https://github.com/mosh-hamedani/vidly-mvc-5/blob/master/Vidly/Controllers/Api/CustomersController.cs)类收到的摘录。实施以下代码后,我收到的错误是>>

无法隐式转换类型'System.Linq.Iqueryable'到System.Data.Entity.DbSet”。存在显式转换(您是否缺少演员)?

此行在此代码上发生

vmrsQuery = vmrsQuery.Where(c => c.Description.Contains(query));

其他人是否有解决方法,以使其正常运行?

public IHttpActionResult GetVMRS(string query = null)
    {

        var vmrsQuery = _context.VMRS;

        if (!String.IsNullOrWhiteSpace(query))
            vmrsQuery = vmrsQuery.ToList().Where(c => c.Description.Contains(query));

        var vmrsDtos = vmrsQuery
            .ToList()
            .Select(Mapper.Map<VMRS, VMRSDto>);

        return Ok(vmrsDtos);
    }

我目前正在尝试通过API搜索查询实现TypeAhead插件。下面的代码是我从udemy类Mosh(https://github.com/mosh-hamedani/vidly-mvc-5/blob/master / ...

javascript api model-view-controller typeahead.js
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.