Search code examples
c#linqwcf-ria-servicesria

WCF RIA - Query operator 'Count' is not supported


I'm trying 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:

Query operator 'Count' is not supported.

I want to basically be able to specify a Where In clause instead of Where =.

Anyone has an idea of how I can achieve this?


Solution

  • Have you tried:

    .SingleOrDefault() != null
    

    I'm not familiar with RIA, but sometimes these kinds of alternate equivalent expressions work with EF.

    Also, with EF, it's possible to do a SQL-style WHERE IN (...) using .Any(...).

    Off the top of my head, this kind of thing works:

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

    ids may be a list of IDs, another list of entities or a subquery, IIRC.