locked
Linq Filtering RRS feed

  • Question

  • I'm trying out the Linq filtering capabilities in Robotics Developer Studio 20. The documentation is not exactly clear. Here's what I have so far:

     

    Code Snippet

    public class UpdateData : Update<int, PortSet<DefaultUpdateResponseType, Fault>>
    {
    }

     

    public class DataUpdateFilter : DataContractFilter
    {
        public int DataId { get; set; }

        public DataUpdateFilter()
        {
            Expression<Func<UpdateData, IEnumerable<UpdateData>>> exp =
             (UpdateData message) =>
                  from item in new UpdateData[] { message }
                  where (item.Body == DataId)
                  select item;

            base.QueryHandler = exp.Compile();
        }
    }

     

     

    When I add this to the subscription header and try to subscribe, I get the following error:

    Specified argument was out of the range of valid values.
    Parameter name: Filter type must have a single method returning a lambda expression

     

    Okay, so I added a method that returned the expression and still no luck.

    1. Am I even close to the right way to do this?
    2. What am I missing?

    Thanks for the help. I hope I'm not missing something super obvious!

     

    C. Stacy Harris

    Monday, April 21, 2008 3:42 PM
    Moderator

Answers

  • we are very restrictive in the number of methods your class can make public and available. We allow fields, and a constructor that sets up the filter, and thats it (for now).

     

    Can you please include the subscribe code and any console/output logs from what you have tried? The example in the documentation are from working code and they work as is (try them against the console/output service for example)

     

    thanx

    g

     

    Monday, April 28, 2008 9:29 PM

All replies

  • Well, I made some progress. If I use fields instead of properties,  I no longer get the error. I'll have time later today to look at this in more detail to see if I can get the kind of filtering I want.

     

    In the meantime, if other people have tried this feature, let me know what you've found.

     

    Stacy
    Tuesday, April 22, 2008 12:28 PM
    Moderator
  • Had a chance to try my solution. I'm still not getting filtering. I must be missing a step somewhere. Any ideas?

     

    Thanks,

    Stacy

     

    Tuesday, April 22, 2008 5:59 PM
    Moderator
  • we are very restrictive in the number of methods your class can make public and available. We allow fields, and a constructor that sets up the filter, and thats it (for now).

     

    Can you please include the subscribe code and any console/output logs from what you have tried? The example in the documentation are from working code and they work as is (try them against the console/output service for example)

     

    thanx

    g

     

    Monday, April 28, 2008 9:29 PM