Group by/count in LINQ against SQL Compact 3.5 SP2
- by bash74
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
}
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