views:

1207

answers:

2

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.

A: 

It seems to be a current limitation of RIA Services. Have a look at MSDN forum

Timores
Thanks. Not the answer I wanted, but it is an answer.
Cylon Cat
I fully agree (that it is not the answer that many people, including myself), as I had tried this also. The thread seems to hint at MS being able to remove the limitation.
Timores
A: 

I'm looking at options for a workaround to this problem that will work for my app, but I was wondering... would it work to just pass a collection of the objects serialized to xml strings (so pass a List, for example), and then use the SilverlightLinq to XML functionality within the Linq statement in your RIA Services domain service query to assign the data from your objects to your query?