Open stephenhauck opened 5 years ago
Hi @stephenhauck, LiteDB implements same conecpt of DbRef as MongoDB. DbRef are just a new object with 2 parameters: { $ref:"collection-name-referece", $id: cross-object-id }
If you want that all sub documents must be a reference, maybe you should review conecpts about DocumentStore database. DbRef should be avoid as much as possible.
I always recommend this "Data Modeling" section on MongoDB documentation because all concepts here are used in LiteDB
https://docs.mongodb.com/manual/core/data-modeling-introduction/
I have seen that before. I simply wanted to know if there were global settings / an option to make it behave the way I would like it to in this specific conversion by default without the extra annotations.
I am a little confused about exactly when BSON attributes are required and such.
I am looking at https://github.com/mbdavid/LiteDB/wiki/DbRef
It indicates that if I want "customers" in a separate file I must include the annotation
[BsonRef("customers")] // where "customers" are Customer collection name public Customer Customer { get; set; }
Is there a way to configure this to be the case for all complex types by default ?
Also, is there a way to configure a type (the Order type below) or all queries to automatically retrieve the related data (using include or an attribute in the top level model) so I don't have to use the "include" like in the code below?
// repository fluent syntax db.Query<Order>() .Include(x => x.Customer) .Include(x => x.Products) .ToList();