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

Closed Issue: OData: nullreference exception when return collection of anonymous typed objects [336]

$
0
0
public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}

public class ShortPerson
{
public string FirstName { get; set; }
public string LastName { get; set; }
}

public class ValuesController : ApiController
{
// GET api/values
[Queryable]
public IQueryable Get()
{
var personList = new List<Person> {
new Person {Id = 1, FirstName = "John", LastName="Smith"},
new Person {Id = 2, FirstName = "Eugene", LastName="Agafonov"}
};
var query = from p in personList select new { p.FirstName, p.LastName };
//var query = from p in personList
// select new ShortPerson{ FirstName = p.FirstName, LastName = p.LastName };

return query.AsQueryable();
}
}

/*
in this scenario, I get an exception accessing http://host/api/values?$top=1
if I uncomment the other variant, it works
*/
Comments: Verified in latest build

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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