Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

CosmosCollectionAttribute breaks POCO benefits #83

Open
RobEyres opened this issue May 2, 2019 · 5 comments
Open

CosmosCollectionAttribute breaks POCO benefits #83

RobEyres opened this issue May 2, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@RobEyres
Copy link

RobEyres commented May 2, 2019

We're trying to refactor our Cosmos entity models to allow them to be reused over numerous projects / applications. One of the big problems introduced was that the entities are now marked up with [CosmosCollection] but we don't want to drag in a dependency to Cosmonaut everywhere the entities are referenced (the consuming libraries have nothing to do with Cosmos or storage concerns).

Would it be possible to abstract the concepts of "entity to collection mapping" and also partition key mapping away by providing an interface. E.g. By having a ICosmosEntityToCollectionMapper type class, the consumer can get away without having to mark up entities with Cosmonaut attributes.

Perhaps the default ICosmosEntityToCollectionMapper could rely on Cosmonaut attributes and fall back on convention as is the current behaviour.

Anyway...please let me know what you think. I could always spike this concept in a branch if this would help?

@Elfocrash
Copy link
Owner

Hey Rob,

Those are all solid points. I would like to see a more detailed example of your proposal to potentially add it as an alternative to the existing solution with the attribute.

@RobEyres
Copy link
Author

Ok...give me a little time to flesh out a POC. Will get back to you. Thanks

@roberino
Copy link

Hey...I created a POC on a fork...take a look at IEntityConfigurationProvider and related implementations.

I think something like this will allow the collection and partition configuration to be defined completely separately from entities while still supporting the default attribute based configuration of entities.

https://github.com/roberino/Cosmonaut/tree/feature/collection-mapping

@Elfocrash
Copy link
Owner

I really like this approach. Feel free to clean it up, write tests and create a PR. Make sure it's backwards compatible.

@roberino
Copy link

Done :) #97

@Elfocrash Elfocrash added the enhancement New feature or request label Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants