Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: OData support for Int64 keys seems to be lacking [936]

$
0
0
OData support for Int64 key seems to be lacking (I also accept I may be doing something wrong)

Run:
http://localhost/MyTypes(2886753098675309)

Result:
{

"odata.error": {
"code": "",
"message": {
"lang": "en-US",
"value": "The request is invalid."
},
"innererror": {
"message": "The parameters dictionary contains a null entry for parameter 'key' of non-nullable type 'System.Int64' for method 'System.Net.Http.HttpResponseMessage Get(Int64)' in 'System.Web.Http.OData.EntitySetController`2[OdataProblemDemo.Controllers.MyType,System.Int64]'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.",
"type": "",
"stacktrace": ""
}
}

}

And yet it works for an Int32

type definition:
public class MyType
{
public long Key { get; set; }
}

Controller (SHouldn't need decorating with [FromODataUri], but makes no difference):

public class MyTypesController : EntitySetController<MyType, long>
{
protected override MyType GetEntityByKey(long key)
{
return new MyType {Key = key};
}
}

and in global.asax
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<MyType>("MyTypes");
var model = modelBuilder.GetEdmModel();
GlobalConfiguration.Configuration.Routes.MapODataRoute(
routeName: "OData",
routePrefix: null,
model: model);

Comments: Glad that it is working now. Can you please close the issue?

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>