Closed kklan closed 6 years ago
You can just have both your ICosmosStores
in the same contractor.
The .NET Core DI framework doesn't support multiple contractors.
You can also use the [FromServices]
attribute to get the store in the specific method.
Is there anyway you can provide an example of syntax when you say both ICosmosStores
in same contractor?
Something like this
private readonly ICosmosStore<Car> _carStore;
private readonly ICosmosStore<FriendStore> _friendStore;
public HomeController(ICosmosStore<Car> carStore, ICosmosStore<FriendStore> friendStore)
{
_carStore = carStore;
_friendStore = friendStore;
}
Great thank you.
Opps close it too soon.
I made the change and it's still not liking that. It's not creating the second collection.
I just had to add in Startup.cs
services.AddCosmosStore<Car>(settings); services.AddCosmosStore<Friend>(settings);
So I was following what you suggested that I create another collection to save relationships.
This is how I set it up:
Model
Initiation:
Post Method:
But I'm getting error:
Do I need to create another controller to handle this?