向RIA服务传递应用程序定义的对象列表时遇到问题。我得到一个编译错误,说“域操作条目‘GetPagedExams’的错误参数‘filters’必须是预定义的可序列化类型之一。”
以下是DomainService中的查询:
[Query]
public IQueryable<ExamEntity> GetPagedExams(int first, int pageSize, List<FilterOptions> filters, List<string> sortDescriptions)
{
return Context.Exams.GetPagedExams(first, pageSize, filters, sortDescriptions).Data.AsQueryable();
}
筛选器选项类定义为:
[DataContract]
[Serializable]
public class FilterOptions
{
public enum FilterAction
{
Equals,
NotEquals,
LessThan,
LessThanOrEquals,
GreaterThan,
GreaterThanOrEquals,
Like,
NotLike,
IsNull,
IsNotNull
}
[DataMember]
[Key]
public string FieldName
{ get; set; }
[DataMember]
public FilterAction FilterOp
{ get; set; }
[DataMember]
public object FieldValue
{ get; set; }
添加DataContract和DataMember属性没有帮助。
我需要传递数量可变的过滤约束,这些约束将作为服务器端SQL查询的一部分进行组装,因此对象列表是必不可少的(是的,它的底层是原始SQL,数据库可以是sqlserver或Oracle。所以我不能使用LINQ,Silverlight客户端也不能知道我在使用哪个数据库。)
有什么建议吗?我正要尝试从客户机传递一个XML序列化,并在服务器上对其进行重新水合。那真的不是我的首选。。。。