c# - Bad request exception in OData request -
c# - Bad request exception in OData request -
during execution of snippet
var res = ctx.resources.where( t => t.resourceid == "t/15") .first();
the programme throws bad request - error in query syntax exception.
the problem '/' char string.
it of import note resourceid string , "the key" of resources entity.
the special char mandatory in our system.
this error occurs since special characters /
have escaped in odata request. in .net framework utilize uri.escapedatastring method purpose, example:
var encresourceid = uri.escapedatastring("t/15"); var res = ctx.resources.where( t => t.resourceid == encresourceid) .first();
it assumed specified query transformed next odata request:
http://localhost/odata/resources()?$filter=resourceid eq 't%2f15'
c# linq odata
Comments
Post a Comment