Reputation: 18739
Using Linq2SQL in the Visual Studio designer, I can define an association expressing a foreign-key relationship that isn't inferred from the database schema, and then use it in queries to merrily dot notate my way across relationships.
This is spectacularly handy with the sort of self-join typically used to express arbitrary hierarchies. These are often not declared relationships because the root is an orphan. Personally I solve the problem by making the root its own parent, which is just as easy to find in a query and allows me to declare the relationship, but most of the world doesn't seem to have thought of this and today I find myself dealing with such a case. I can't fix it because legacy code uses null parent to find the root.
So... I define the association in the Linq2SQL designer, which is fine as far as it goes. But I'd like to test my queries in Linqpad, and this leads to the question:
(How) can I define associations between inferred entities in Linqpad?
When using this technique to deliver data through Web API:
Another more common approach is to respond to node expansion (in a tree) by fetching the immediate children of the node.
Upvotes: 1
Views: 143
Reputation: 16067
You can use your existing design by creating a new connection and selecting Use a typed data context from your own assembly.
Upvotes: 1