【发布时间】:2012-10-03 10:01:35
【问题描述】:
我只想从字符串eventTriggers 中选择字段为“1”的记录(看起来像这样:“00100010”)
我已经尝试并成功完成了超过 1 次调用.. 但我怀疑它的效率。基本上我想要这样的东西......但显然 LINQ 不支持这个。
(LINQ to Entities does not recognize the method 'Char get_Chars(Int32)' method, and this method cannot be translated into a store expression.)
using (var service = new dB.Business.Service.BaseBusinessService<memo>())
{
List<memo> result = service.Repository.GetQuery().Where(p => p.ID == ID && p.eventTriggers[index] == '1').ToList();
}
关于正确解决方案的任何提示?谢谢 !
【问题讨论】:
-
我正在使用存储库...一秒钟我将编辑
-
后面的数据库是什么仍然很重要。基本上,如果您希望能够在数据库中执行此过滤,您需要以 LINQ 可以转换为数据库可以理解的形式来指定它。如果您有足够少量的数据,并且很乐意在过滤之前将其全部从数据库中取出,只需在
.Where()之前添加一个.AsEnumerable()。
标签: linq linq-to-entities