Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

CosmosEntityName set does still pluralize classname in db. #34

Closed MatsJakobsson closed 5 years ago

MatsJakobsson commented 5 years ago

Hi,

I have set the Property CosmosEntityName but AddAsync still persists with my classname pluralized.

Is this a known issue?

Thanks!

Elfocrash commented 5 years ago

Hey Mark,

Are you manually setting the value of the CosmosEntityName every time you try to perform an action?

It is not meant to work like that. You can instead set the EntityName value at the SharedCosmosCollection attribute level.

Reading the shared collections section of the readme page would also help.

Let me know if that’s unclear.

Thanks, Nick

MatsJakobsson commented 5 years ago

Hi,

Ah, thanks! Works like a charm when setting it on the attribute!

I did not find it as obvious when reading the section on "shared collections", maybe I was reading to quickly or maybe it can be clarified?

Another question, related to this, now that I have set my desired entityname in the attribute, I still need to to implement ISharedCosmosEntity and the member CosmosEntityName. But it seems unnecessary? Is there a way around this so that I can keep my code cleaner or is it vital for some other reason that I do not understand?

Thanks again for a great tool and for a quick response. Keep up the good work!

Elfocrash commented 5 years ago

Glad it works! I will update the documentation to make this more obvious.

The interface implementation is necessary for multiple reasons. The main one is because Cosmonaut will use an Expression to add the shared collection entity name in the where clause in order to limit your results. That cannot happen unless the property is part of the class and the cleanest way to ensure it (without using reflection) is an interface which forces you to implement it.

Is the interface implementation messing up something on your system?

Thanks!

Elfocrash commented 5 years ago

Closing this due to inactivity. Feel free to reopen it if you need to reply. Thanks!