-
Notifications
You must be signed in to change notification settings - Fork 136
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
Restier cannot handle more than one API registered per app. #527
Comments
I checked the source code, it is not directly two API (In fact, we create one container per API, it should not cause issue). BTW, we will have China National Holiday from 10/1-10/7, and I will take three additional leave (9/30, 10/8-10/9), the response will be slow. We are welcome and appreciated any contributions. For the code which throws exception per call stack you paste.
|
I am not using more than one EntityContainer, and I'm only using one DbContext per API. I tried registering custom ModelBuilders as per the 1.0.0 beta after the error was thrown the first time, but that had no effect. Technically, this code should probably be looping through each Container, shouldn't it? At the very least, it should be calling . |
If you do not want any restier model builder code been called. You need to call configureApi method first, then register your service. This means your service will be the end of the chain and it will be called first, and in your service, you can decide whether to call services registered before your service. |
So, we've had the discussion about how what you described is not how DI is supposed to work, I won't re-hash it. When I changed the code to Once I find the problem, the unit tests will need to be updated to check that more than one API pointing to more than one DbContext can be registered properly and return the proper metadata. |
It appears that the design for Restier did not take into account the possibility that more than one API could be registered with inside a single project.
Assemblies affected
RESTier 1.0.0-beta
Reproduce steps
Register 2 APIs in a single project using MapRestierRoute.
Expected result
I would expect a request to the service to return normally.
Actual result
The Dependency Injection system is throwing an error because there is more than one model registered, but the call is apparently calling the LINQ
.Single()
function, which only expects one element. It should likely be calling.FirstOrDefault()
instead and checking for a null result.The text was updated successfully, but these errors were encountered: