Take the 2-minute tour ×

Console application

var result = dataService.CreateQuery<Customers>("GetCustomerByLastName").
    AddQueryOption("lastname", "S");


    public IQueryable<Customers> GetCustomerByLastName( string lastname )
       return   from c in this.CurrentDataSource.Customers
                where c.LastName.StartsWith( lastname )
                select c ; 

results in: (relative to http://localhost:1478/Apress.Data.Services.CustomerService.Host/)

RequestUri: CustomerDataService.svc/GetCustomerByLastName()?lastname=S

and fails as a result , because of parentheses in uri , which are not expected.


works in a browser.

VS 2008 SP1 .

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

It turned out the problem was not related to parentheses , I was missing string literal single quotes

should be

AddQueryOption("lastname", "'S'");





both correct for ADO.Net Data Services.

share|improve this answer
add comment

You've probably tried this already, but what happens without the AddQueryOption? I know it won't pass the parameter, but does that change the issue with parentheses? Also, what happens if you do that and change the service to not require the parameter? Same question about parentheses.

Finally, if this turns out to be a bug, then please report it on Connect. Then post the URL here so we can vote on how important we feel the problem is. Be sure to do a search first to see if someone else has reported it.

share|improve this answer
add comment

Your Answer


