Closed iroman91 closed 4 years ago
Is a known issue. Reported it as well with the previous issues. Author of package is aware. All dto properties are returned. Look at the issue regarding orderby
Get Outlook for Androidhttps://aka.ms/ghei36
From: Roman Ivakin notifications@github.com Sent: Thursday, February 6, 2020 10:29:51 AM To: AutoMapper/AutoMapper.Extensions.OData AutoMapper.Extensions.OData@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [AutoMapper/AutoMapper.Extensions.OData] $select query doesn't work (#10)
Instead of returning the specified properties from a $ select query, GetAsync or GetQueryAsync will return all (selected + unselected) properties.
Model/Dto:
public class User {
public int Id { get; set; } public string Name { get; set; } }
OData select query: $select: id
GetAsync method:
ICollection
Output:
{ Id: 1 Name: "TestUser" }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/AutoMapper/AutoMapper.Extensions.OData/issues/10?email_source=notifications&email_token=AIMW3QURCYYPNP4IKPMGKZTRBPKA7A5CNFSM4KQZM4K2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ILONDKA, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIMW3QT33HSYEGAP3VGYQWLRBPKA7ANCNFSM4KQZM4KQ.
Thanks for your reply. Hopefully, the author will be able to fix this soon.
I was too quick to reply, my bad.
If you are talking about the json returned by the odata call, then the select should be applied correctly.
However, the generated SQL from EF Core includes all of the DTO properties instead of only the ones in the $select clause.
No we need an implementation for $select to return an anonymous type. I'll leave this open until it's ready.
Should be working using QueryableExtensions.GetQueryAsync in version 1.0.2-preview04. See the unit tests.
Hi,
This doesn't appear to work in the latest version (1.0.5) when the DTO has non-nullable value typed properties on it. These still come through (albeit as their natural "default" value).
Instead of returning the specified properties from a $select query, GetAsync or GetQueryAsync will return all (selected + unselected) properties.
Model/Dto:
OData select query:
$select: id
GetAsync method:
ICollection<User> result = await sourceQueryable.GetAsync(mapper, odataOptions);
Output
: