question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Include Functionality For Nested Object , like v4 Includeall ?

See original GitHub issue

I am stuck on finding solution for below query. using litedb v5

Query : db.GetCollection<PurchaseOrder().Include(x=>x.OrderItems) , want to include Model DTOs :

public class PurchaseOrder
    {
        public int Id { get; set; }
        public DateTime DatePurchased { get; set; }
        public List<OrderDetail> OrderItems { get; set; }
        public string Note { get; set; }
    }
 
  public class OrderDetail
    {    
        public Model Model { get; set; }
        public decimal Price { get; set; }
        public int Qty { get; set; }
    }
 public class Model 
    { 
        public int Id { get; set; }
        public string Name { get; set; }
  }

Issue : when i run above query it gives me result but Model is is always null. Any help will be appreciated !!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
jaimin-pcommented, Apr 26, 2020

db.GetCollection<PurchaseOrder>().Include("$.OrderItems[*].Model") Thanks !! It works. Is there any way to define IncludeAll ? without explicitly specifying each dbRef ?

1reaction
zmiracommented, Apr 25, 2020

totally missed the fact that OrderItems was a list and that, probably OrderItems isn´t BsonRefed 🙄

assuming only Model is declared as BsonRef, how about db.GetCollection<PurchaseOrder>().Include("$.OrderItems[*].Model");?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested include in sequelize?
This solution does not work as written (at least not in the version I have, 3.24.1). The inner include should be 'include: [models.users]'....
Read more >
Working with nested arrays
I have a nested json that I'm using the Arrays function under data manipulation to pull out information using Find All.
Read more >
Nested field type | Elasticsearch Guide [8.9]
The nested type is a specialised version of the object data type that allows arrays of objects to be indexed in a way...
Read more >
Persistent Object Systems 7 (POS-7) - Page 165 - Google Books Result
Also , for each attribute , the extent table includes information used to ... features of the nested relational and complex object data...
Read more >
top-nested operator - Azure Data Explorer
The top-nested operator performs hierarchical aggregation and value selection. Imagine you have a table with sales information like regions, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found