Lite
Lite
LiteDB
rk
m
e
on
G
itH
Docs
ub
Getting Started
Data Structure
Object Mapping
Collections
BsonDocument
Expressions
DbRef
Connection String
FileStorage
Indexes
Encryption
Pragmas
Collation
DbRef
LiteDB is a document database, so there is no JOIN between
collections. You can use embedded documents (sub-documents) or
create a reference between collections. To create a reference you can
use [BsonRef] attribute or use the DbRef method from the �uent
API mapper.
Note that BsonRef decorates the full object being referenced, not an
int customerid �eld that references an object in the other collection.
BsonMapper.Global.Entity<Order>()
.DbRef(x => x.Customer, "customers"); ∕∕ where "customers" are Custome
Now, when you store Order you are storing only the reference.
Querying results
When you query a document with a cross-collection reference, you can
auto load references using the Include method before query.
BsonMapper.Global.Entity<Order>()
.DbRef(x => x.Products, "products");
orders.Include(n
new string[] { "$.Customer", "$.Products[*]"