我有一个使用 EF 模型运行 RIA 服务的 C#.NET Silverlight 3.0 客户端。我正在尝试在客户端上设置一个高级搜索系统,以便用户可以说,我希望字段(属性)“Foo1”具有值“Bar1”等。
我想使用一种与此类似的灵活、动态的方法。问题是我不能将 IQueryable 作为 ServiceOperation 参数或域服务参数传递。IE 这不起作用:
[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;
}
任何人都可以提出一种让这种方法发挥作用的方法或另一种(更好的)方法吗?目标是一个灵活的搜索控件,可以应用于多个特定实体类型。