Is there an entity infrastructure for prefetching paths?

I am moving from one ORM to another (LLBGen Pro for Entity Framework). To properly reorganize, I need to understand something. LLBGen Pro has a concept called the prefetch path . Prefetching paths exist to reduce the number of queries required when lazy loading adversely affects performance. In Gen Pro, let's say I have 50 orders, and I want to collect the customer associated with each order. With lazy loading, I could get 51 DB queries. 1 for orders and another 50 for each client due to lazy loading of clients compared to two requests with prefetch paths enabled.

I understand that the entity framework (or maybe LINQ to SQL) generates the most optimal SQL for the situation. Is Entity Framework smart enough to optimize queries when LLB Gen Pro cannot? In other words, the entity structure generates SQL at runtime intelligently, where can it “look ahead” and see the need for all clients and generate one query, rather than 50 separate queries? Or does EF support some type of “prefetch path” or does it require some advanced custom expression trees ... etc?

+4
source share
1 answer

EF is not so smart yet.

I think you are looking for Include . This function allows you to load related objects.

+4
source

Source: https://habr.com/ru/post/1493203/


All Articles