WCF RIA - Count query operator not supported

I am trying to use the following code.

LoadOperation<Tasks> PhasesLP = context.
    Load(context.GetTasksQuery().
    Where(o=> ProjectList.Where(p=> p.ProjectID == o.ProjectID).Count() == 1)  

I get the following error:

The query operator "Count" is not supported.

Basically I want to specify a sentence Where Ininstead Where =.

Does anyone have an idea how I can achieve this?

+5
source share
1 answer

You tried:

.SingleOrDefault() != null

I am not familiar with RIA, but sometimes these alternative equivalent expressions work with EF.

In addition, with EF you can use WHERE IN (...)SQL-style with .Any(...).

From the top of my head, this works:

entities.Where(e => ids.Any(i => e.Id == i))

ids may be a list of identifiers, another list of objects or a subquery, IIRC.

+2
source

All Articles