Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$select not working on property HasConversion #2010

Open
keatkeat87 opened this issue Jan 8, 2020 · 5 comments
Open

$select not working on property HasConversion #2010

keatkeat87 opened this issue Jan 8, 2020 · 5 comments
Labels

Comments

@keatkeat87
Copy link

keatkeat87 commented Jan 8, 2020

when a property use ef core HasConversion like convert to json, $select query when break down.
image
error message as above.

Assemblies affected

*Which assemblies and versions are known to be affected
asp.net core 3.1, odata 7.3 beta

Reproduce steps

1.git clone https://github.com/keatkeat87/odata--select-HasConversion-issue.git
2.dotnet ef migrations add init
3.dotnet ef database update
4.F5
5.visit /api/people?$select=cars

the $select can work every property except "cars".

i found that for single "car" is ok, for collection "cars" is not ok.

below is the edm
#2010 (comment)
image

@xuzhg
Copy link
Member

xuzhg commented Jan 9, 2020

@keatkeat87 Thanks for reporting this issue.

I tested using our sample project on Collection of complex type, it works fine. However, my sample uses the in-memory data base.

Could you please try to "decorate" [Owned] on your "car" type and let us know your result?

See commit at: 6f9052a

@keatkeat87
Copy link
Author

@xuzhg Thanks for your reply.
I have test your idea, using Owned & OwnsMany will work as expected.
why don't I use complex type instead of HasConversion + json
is because of #196
i m just look back to the issue and it already been fixed.
so currently i don't need to use json any more.
for me the problem is not effect for my project now.
but i don't know what to do think about $select + HasConversion json array problem.
I already update the Github repository,
image
if you switch to use HasConversion
then $select=images will get the error.
$select=image is work good.
if you not interesting to check further then you can close this issue as well.

@xuzhg
Copy link
Member

xuzhg commented Jan 14, 2020

@keatkeat87
It might be related to EF Core. Can you file an issue at https://github.com/dotnet/efcore/issues/new/choose

@keatkeat87
Copy link
Author

@xuzhg I already create other issue in EF Core.
but i test direct call ef, the code will just work.
image
is it possible there is a problem during the conversion odata query to expression.
i don't know how to debug for that. maybe be you can point out what you guess to let ef core team easy to solve the problem.

@HorunS
Copy link

HorunS commented May 26, 2020

Hello.
We have the same problem. We use HasJsonConversation for string property to work with string as with Listobject (model has text property "FilesInfo" in DB and we convert it to List Files; so basically we store json array in string property and work with it via conversation to our custom type).
It works fine with custom api and odata query(it returns array of FileInfo instead of just string background property), but! it doesn't work in cases if we add any $select or $expand to query. In those cases OData starts to skip Files property(but it works fine with order by, filter, top and so on).

image

Please help: how to setup odata to support "HasConversation" properties.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants