asp.net-mvc – LINQ to Entities无法识别方法异常
发布时间:2020-10-19 06:50:42 所属栏目: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字符串分割函数使用方法分享
- asp.net – Windows应用程序与Web应用程序开发
- asp.net – 我应该使用WebMatrix构建一个真实世界的网站吗?
- ASP.NET代码隐藏中的当前工作目录 – 我们可以依赖它吗?
- asp.net-mvc – 使用AWS .NET SDK进行SNS订阅确认示例
- ASP.NET对txt文件相关操作(读
- asp.net – 如何在页面加载时以“添加新”模式进行编程设置
- asp.net 2.0中利用Ajax2.0实现JSON传送大量页面数据
- asp.net-mvc – 根据浏览器接受语言自动设置uiCulture
- 如何将数组从Asp.net服务器端传递到客户端的Javascript函数
推荐文章
站长推荐
- ASP.NET VNext类库System.Runtime.Serialization
- asp.net-mvc – MVC应用程序调试错误:viewstate
- asp.net下大文件上传知识整理
- ASP.NET拒绝访问该路径
- asp.net-web-api – Web Api:找不到System.Net.
- asp.net core 实现一个简单的仓储的方法
- asp.net-mvc – ASP.net MVC:在RenderAction中获
- asp.net-mvc – 我可以从服务器端的持票令牌中检
- 在ASP.NET MVC中动态地从数据库生成CSS文件
- Asp.net(C#)读取数据库并生成JS文件制作首页图片
热点阅读