How can I encode a recursive query in an Entity Framework model?

I have a model that includes NODES and RELATIONSHIPS (which link nodes together using parent_node, child_node).

Q1 - Is there a way in EF / Linq-to-entity to execute a query on nodes (for example, context.Nodes ..) to find “all parents” or “or children” on the graph?

Q2 - If there is no in Linq-to-entity, is there any other way to do it differently than to write a method that passes manually and does it?

Q3. If guidance is the only way to do this, should I worry about the number of database calls that will arrive in the database as the method continues recursing through the data? Or, more specifically, is there an EF caching function that can help here to ensure the effectiveness of the method in terms of "number of database calls"?

thank

thank

+3
source share
2 answers

. ( proc ) , , , . , , .

+1

Microsoft SQL Server 2005 CTE ( ). . SQL Server , , , - .

, proc SQL-, EF .

+1

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


All Articles