Prev | Current Page 581 | Next

Jon Skeet

"C# in Depth: What you need to master C# 2 and 3"


?–  I renamed DefectUser to User (so although the table is still called DefectUser,
we??™ll generate a class called User, just like before).
317 LINQ to SQL
?–  I changed the type of the Severity, Status, and UserType properties to their
enum equivalents (having copied those enumerations into the project).
?–  I renamed the parent and child properties used for the associations between
Defect and DefectUser??”the designer guessed suitable names for the other
associations, but had trouble here because there were two associations between
the same pair of tables.
Figure 12.1 shows the designer diagram after all of these changes.
As you can see, the model in figure 12.1 is exactly the same as the code model
shown in figure 11.3, except without the enumerations. The public interface is so similar
that we can create instances of our entities with the same sample data code. If you
look in the C# code generated by the designer (DefectModel.designer.cs), you??™ll
find five partial classes: one for each of the entities, and the DefectModelDataContext
class I mentioned earlier. The fact that they??™re partial classes is important when it
comes to making the sample data creation code work seamlessly. I had created a constructor
for User, which took the name and user type as parameters. By creating
another file containing a partial User class, we can add that constructor to our model
again, as shown in listing 12.


Pages:
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593