控制台应用程序
var result = dataService.CreateQuery<Customers>("GetCustomerByLastName").
AddQueryOption("lastname", "S");
服务
[WebGet]
public IQueryable<Customers> GetCustomerByLastName( string lastname )
{
return from c in this.CurrentDataSource.Customers
where c.LastName.StartsWith( lastname )
select c ;
}
结果:(相对于http://localhost:1478/Apress.Data.Services.CustomerService.Host/)
RequestUri: CustomerDataService.svc/GetCustomerByLastName()?lastname=S
并因此失败,因为 uri 中的括号不是预期的。
CustomerDataService.svc/GetCustomerByLastName?lastname='S'
在浏览器中工作。
与 2008 SP1 相比。