[英]Specified method is not supported when using Count() in Linq with Nhibernate
When I am using .Count()
I am getting this error: 当我使用.Count()
时,出现此错误:
the specified method not supported 指定的方法不受支持
At this line am getting error like Sql not found
: 在这一行正在得到类似Sql not found
错误Sql not found
:
session.Query<Table>().Select(x => new { x.Id }).Distinct();
This is the full code: 这是完整的代码:
var List = session.Query<Table>().Select(x => new { x.Id }).Distinct();
foreach (var id in SelectedIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
var count = List.Where(x => x.Id == Int32.Parse(id)).Count();
if (count > 0)
{
}
}
Is it problem with Nhibernate or am i missing something? Nhibernate有问题吗?还是我缺少什么?
Try to put out the cast like this: 尝试按如下方式投放演员表:
int idCompare = Int32.Parse(id);
var count = List.Where(x => x.Id == idCompare).Count();
Linq is not able to convert every .NET Framework advanced function to sql. Linq不能将每个.NET Framework高级功能都转换为sql。
Maybe this solves your issue. 也许这可以解决您的问题。
When you need to check whether a .NET method is available in linq you might want to check this source and also this 当您需要检查的.NET方法是否在LINQ提供你可能要检查这个来源 ,也该
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.