RIA EF4 复杂的多对多过滤器
首先,我很抱歉我的英语不好。
我有一个类似于以下内容的数据库结构:
将 RIA 服务与 EF4.1 结合使用什么是最好的方法仅选择具有某些特征的汽车?
在客户端上,用户可以选择多个“特性”并告知一个值。 然后,我需要显示具有该特定值的特征的所有汽车(“值”保存在 CarCharacteristic 表中) (类似于所有具有“2”(CarCharacteristic)“门”(Characteristic)的“汽车”(Car))
我想要在客户端上执行此操作,但似乎不可能:(
为了能够在服务器上过滤此内容,我需要至少向每个特征发送所选特征的所有特征 ID 和用户通知值。
问题是,如果我创建一个查询任何复杂(例如 MyClass[])参数我收到错误:
域操作条目 'GetCarsByCharacteristic' 的参数 'x' 必须是预定义的可序列化类型之一
我认为我在这里遗漏了一些明显的东西,因为它不能这么难...
做这种事情的正确方法是什么?
first of all sorry for my bad english.
I have a DB structure similar to that:
Using RIA Services with EF4.1 what would be the best way to select only the cars that has some Characteristics?
On the Client the user can select multiple "Characteristic" and inform a Value.
I then need to show all the Cars that has that Characteristics with that specific value (the "value" is saved on the CarCharacteristic table)
(something like all "cars" (Car) that have "2" (CarCharacteristic) "doors" (Characteristic))
I would like to do this on the client but it seems it is not possible :(
To be able to filter this on the server, I need to send at least all the CharacteristicId of the selected Characteristics and the user informed value to each one.
Problem is that if I create a query with any complex (e.g MyClass[]) parameter I get the error:
Parameter 'x' of domain operation entry 'GetCarsByCharacteristic' must be one of the predefined serializable types
I think I am missing something obvious here because it can't be so hard...
How would be the right way to do this kind of thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,由于您想要发送一个数组作为查询的参数,因此您需要使用
HasSideEffects=true
属性标记查询,如下所示:现在您可以发送您的自己的类作为参数(我不确定,我还没有检查过),但是你绝对可以使用
Dictionary
类型的参数,我假设Guid< /代码>是您用于
Ids
的类型,而int
是值。现在,您可以根据需要按 ID 和值过滤集合。
编辑:
另外,您没有提到使用
DomainDataSource
,所以我猜测您正在使用DomainContext
对象。在这种情况下,您可以像这样添加过滤客户端:First of all, since you want to send an array as a parameter of a query, you'll need to mark the query with
HasSideEffects=true
attribute, like so:Now you MIGHT be able to send your own class as a parameter (I'm not sure, I haven't checked yet), but you can definitely use a parameter of type
Dictionary<Guid, int>
where I assumeGuid
is the type you use forIds
, whileint
is the value.Now you can filter the set by Ids and the values as needed.
EDIT:
Also, you didn't mention using a
DomainDataSource
, so I'm guessing you're working with aDomainContext
object. In this case, you can add the filtering client-side like so: