You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varquery=newODataQueryBuilder().For<Thing>("Things").ByList()// expected: title,id// actual: Title,Id.Select(x =>new{x.Title,x.Id});// allow multiple select as a solution?//.Select(x => x.Title)//.Select(x => x.Id)// or introduce another approach for selecting several columns?varparts=query.ToDictionary();
We get value Title,Id for $select but expecting title,id.
The documentation talks about using .Select(s => new { s.Id, s.Sum, s.Type }).
The text was updated successfully, but these errors were encountered:
By default, when you use new { x.Title, x.Id }, C# automatically assigns the property names based on the original names of the properties in your class, which are Title and Id. This is why you're seeing Title and Id in the output instead of the custom title and id specified by the [ODataPropertyName] attributes.
To resolve this, you'll need to explicitly rename the properties in your anonymous type to match the names you want in the output. You can do this by using this syntax:
.Select(x => new { title = x.Title, id = x.Id })
While it is possible to modify the library to automatically map the [ODataPropertyName] attribute to the names, I don’t think that would be the right call.
Having some class,
the next code doesn't work as expected:
We get value
Title,Id
for$select
but expectingtitle,id
.The text was updated successfully, but these errors were encountered: