dj-nitehawk / MongoDB.Entities

A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management
https://mongodb-entities.com
MIT License
547 stars 70 forks source link

Storing different objects (of different types) with a common base object in single table #224

Closed ssteiner closed 4 months ago

ssteiner commented 5 months ago

Besides having a considerable number of well defined entities, I have one entity where I only know the base structure.

public class BaseEntity: Entity
{
  public string Name {get; set;}
.. other common attributes here
}

The actual entities to store would derive from BaseEntity - but instead of getting the typed object, I'm getting a JSON document. Is there a way to handle with with MongoDB.Entites other than declaring an additional string prop that holds the json? In the official MongoDb driver I'm using a table of BsonDocument which allows for that, but MongoDB.Entities seems much more suited for the rest of what I'm doing.

dj-nitehawk commented 4 months ago

that is currently not supported. see #95 you can always use the official driver for scenarios that are not supported by this library.