在LINQ中针对SQL Compact 3.5 SP2分组/计数 [英] Group by/count in LINQ against SQL Compact 3.5 SP2
问题描述
您好,我在C#中使用LINQ-To-Entities并对SQL Compact Server 3.5 SP2运行查询。
我尝试实现的是一个简单的组where子句包含Count()。
Hello, I am using LINQ-To-Entities in C# and run queries against a SQL Compact Server 3.5 SP2.
What I try to achieve is a simple group by with an additional where clause which includes a Count().
var baseIdent="expression";
var found=from o in ObservedElements
where o.ObservedRoots.BaseIdent==baseIdent
group o by o.ID into grouped
where grouped.Count()==1
select new {key=grouped.Key, val=grouped};
foreach(var res in found){
//do something here
}
此查询抛出着名的异常"A"此位置不允许参数。确保'@'符号和所有其他参数都在SQL语句中的有效位置。"
$
当我省略where子句或直接输入表达"表达"在查询中(其中o.ObservedRoots.BaseIdent ==" expression")一切正常.│
有人知道如何解决这个问题吗?解决方法也没关系?在此先感谢,塞巴斯蒂安以
This query throws the famous exception "A parameter is not allowed in this location. Ensure that the '@' sign and all other parameters are in a valid location in the SQL statement."
When I either omit the where clause OR directly enter the expression "expression" in the query (where o.ObservedRoots.BaseIdent=="expression") everything just works fine.
Does anybody know how to solve this? Workaround would also be fine? Thanks in advance, Sebastian
推荐答案
您好,
此错误是查询处理器错误之一:
http ://technet.microsoft.com/en-us/library/ms172350.aspx
This error is one of the query processor errors:
http://technet.microsoft.com/en-us/library/ms172350.aspx
目前,您可以直接使用表达式来避免它。如果这是一个紧急问题,请与Microsoft产品支持服务联系:
http://support.microsoft.com/
Currently, you could use the expression directly to avoid it. If it is an urgent issue, please contact Microsoft Product Support Service:
http://support.microsoft.com/
祝你好运
这篇关于在LINQ中针对SQL Compact 3.5 SP2分组/计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!