-
-
Notifications
You must be signed in to change notification settings - Fork 158
Can't create resource with relationship in Entity-Resource separation mode #445
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
Comments
Hm. I would expect that to work just from looking at it quickly. The Course/Department example is very similar. There is no test for this specific scenario though, so let me add one and check it out. |
Quick update. I do indeed get the same error when attempting to add the relationship like this. As a workaround, you can update the relationship after creation (e.g. RelationshipModifyTests) |
@roblankey Thanks for the info. Unfortunately I can't do this as a workaround - several clients are connected to API using about 40 controllers, so I have to keep unseparated flow. Every other operations like inclusion, filter, sort etc. works with no problems. All my acceptance tests fails only in this one use-case. If I'm thinking about solution, it's quite hell of pain :( |
Ok. Makes sense. Let me see what I can do. |
see #446 |
Cool! As @jaredcnance said, the same problem should be also with HasMany (I didnt't try, because we don't have this use-case...for now). |
fix/#445: create resource with relationship in Entity-Resource separation mode
Consider following:
Entities:
Resources:
Three Layer flow (with Automapper Profile)
1) Controller - JsonApiController<ClientResource>
2) Service - EntityResourceService<ClientResource, Client, int>
3) Repository - DefaultEntityRepository<Client>
If I POST request like this:
the InvalidOperationException is thrown, because:
"The entity type 'ParentResource' was not found. Ensure that the entity type has been added to the model."
This exception points to line 234 of DefaultEntityRepository and it's AttachHasOnePointers method.
Do you have any idea, how to handle this? Does this mean, that Repository should be responsible for proper resolve of navigation property type?
The text was updated successfully, but these errors were encountered: