I'm having a problem passing an list of application-defined objects to RIA services. I get a compile error saying "Error Parameter 'filters' of domain operation entry 'GetPagedExams' must be one of the predefined serializable types."
Here's the query in the 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();
}
The filter options class is defined as:
[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; }
}
Adding the DataContract and DataMember attributes did not help.
I need to pass a variable number of filtering constraints that will be assembled as part of an SQL query on the server side, so a list of objects is just about a necessity. (Yes, it's raw SQL underneath, and the database can be either SQL Server or Oracle. So I can't use LINQ, and the Silverlight client can't know which database I'm using.)
Any suggestions? I'm just about to try passing an XML serialization from the client, and re-hydrating it on the server. That's really not my preferred option....
This was a working query when I was passing a single string for a filter, rather than a collection. So I know the problem is strictly with the custom collection.