asp.net-mvc – LINQ to Entities无法识别方法异常
发布时间:2020-10-19 17:08:45 所属栏目:asp.Net 来源:互联网
导读:我有这样的事情 SecuritySearcher sc = new SecuritySearcher();Dictionarystring, bool groupsMap = sc.GetUserGroupMappings(domainName, currentUser, distGroups.ToList());IQueryableHotelTravel groupq =
我有这样的事情 SecuritySearcher sc = new SecuritySearcher(); Dictionary<string,bool> groupsMap = sc.GetUserGroupMappings(domainName,currentUser,distGroups.ToList()); IQueryable<HotelTravel> groupq = (from hotel in qHs join hp in qHps on hotel.HotelTravelId equals hp.HotelTravelId where !string.IsNullOrEmpty(hp.GroupName) && groupsMap.ContainsKey(hp.GroupName) && groupsMap[hp.GroupName] == true select hotel); 在执行Linq语句时,它正在抛出异常说法 解决方法为了将表达式转换为数据库查询,数据库必须以某种方式知道字典的内容并有办法从查询中访问它. SQL中没有字典机制,但这并不重要,因为您不需要字典,因为您只是在寻找值为某个常量的键.您可以将该组密钥转换为列表,并查看该列表是否包含您要查找的内容:var groupsList = (from kvp in groupsMap // find all keys in groupsMap where kvp.Value == true // where the value is set to True select kvp.Key).ToList(); IQueryable<HotelTravel> groupq = from hotel in qHs join hp in qHps on hotel.HotelTravelId equals hp.HotelTravelId where !string.IsNullOrEmpty(hp.GroupName) && groupsList.Contains(hp.GroupName) select hotel; 我怀疑你实际上并没有将空字符串作为字典中的键,这意味着你可以摆脱IsNullOrEmpty调用,只需要在groupsList.Contains(hp.GroupName)中. (编辑:鄂州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.NET 5针对dnx451 / dnx46性能
- asp.net core webapi 服务端配置跨域的实例
- asp.net – WebForms:MasterPages中的动态(或绝对)脚本标记
- 在IIS上部署ASP.NET Core项目的图文方法
- asp.net-mvc – ASP.net身份在删除外部帐户后停止分发外部C
- asp.net-mvc – webgrid中的Mvc 3 texbox(razor)
- Asp.Net 5分钟实现网页实时监控
- asp.net – Orchard CMS和Sitefinity CMS
- asp.net-mvc – 如何将XML作为POST传递给ASP MVC .NET中的A
- asp.net-mvc-3 – ASP.Net MVC 3:在哪里处理会话丢失?
推荐文章
站长推荐
- asp.net – 自动将视频格式转换为Flash Video
- asp.net+ajaxfileupload.js 实现文件异步上传代码
- asp.net-mvc – Gzip压缩无法运行ASP.net MVC5
- asp.net-mvc – RequireHttps导致Amazon Elastic
- asp.net+js 实现无刷新上传解析csv文件的代码
- VS 2013 RC中缺少ASP.NET Web窗体脚手架功能
- ASP.NET通过自定义函数实现对字符串的大小写切换
- ASP.NET(AJAX+JSON)实现对象调用
- asp.net-mvc-3 – 为什么@ Html.Label()删除一些
- asp.net – HttpWebRequest正在为404抛出异常
热点阅读