views:

345

answers:

1

Hi,

I have a C#.NET Silverlight 3.0 client running RIA Services with an EF model. I'm trying to set up an advanced search system on the client such that the user can say, I want field (property) "Foo1" to have value "Bar1," etc.. .

I'd like to use a flexible, dynamic approach similar to this one. The problem is I can't pass IQueryable as a ServiceOperation parameter or as a domain service parameter. I.E. This doesn't work:

[ServiceOperation()]
public int GetFooCount(string category, IQueryable<Foo> search)
{
    int fooCount;
    if (search != null)
    {
     IQueryable<Foo> filteredFooSet = this.Context.FooSet.Intersect(search);
     fooCount = (from foo in filteredFooSet
                 where foo.Category == category
                 select foo).Count();
    }
    else
    {
     fooCount = (from foo in this.Context.ContactSet
                 where foo.Category == category
                 select foo).Count();
    }

    return fooCount;
}

Can anyone suggest either a way to get this approach to work or an alternative (better) approach? The objective is a flexible search control that can be applied to more than any single specific entity type.

+1  A: 

I think your best bet would be to use the Dynamic Linq Library. Using that library you could pass your where clauses as string and then use the library to use that against your EF data.

Bryant
This worked!! Thanks so much!
Nick Gotch