
Chapter 7: Working with Data | 201 |
To add entities to the LINQ to SQL Designer, open Server Explorer, select a database, and open the Tables folder. Then drag and drop the Customer and Order tables from Server Explorer to the left surface of the LINQ to SQL Designer. You can see the Customer and Order classes in Figure
The line between Customer and Order is called an association. As you might guess from reading the previous discussion on class relationships, the association defines the relationship between two classes. Although a relationship between tables is constrained by a foreign key in a child that refers to the primary key of that child’s parent, an association is the reverse direction; it is a property of a parent class that refers to all of the children of that class. When coding, you can use this association to navigate between parent and child objects.
NOTE
Features, such as the difference between foreign key relationships in relational databases and associations in
On the right pane of Figure
If your database has views and functions, you can add them the same way as you did for classes and functions previously. Before showing you how to use these new classes and views, I’ll show a little more about what you can do with the LINQ to SQL Designer.
Working with the LINQ to SQL Designer
While the most important part of the LINQ to SQL Designer is being able to add classes and methods, you should also know about some if its features such as the Methods pane hiding, zooming, and
Most of the time working with the Designer is with classes, and you want as much screen real estate as possible. You can achieve this goal by hiding the Methods pane. Just