Once you have selected the appropriate information, click OK.
The Object Relational Designer currently supports a one-to-one (1:1) mapping relationship. It is a simple
mapper, so complex mappings such as mapping an entity class to a joined table are not supported in this
release.
Extending O/R Designer-Generated Code
LINQ to SQL realizes that there will always be a need for custom logic, so it provides a way to add validation
logic to meet the demands of specific insert, update, and delete scenarios. The custom validation
is provided by the capability to add a partial class, extending the DataContext class. The cool thing about
this is that these custom methods are automatically called when the SubmitChanges() method is called.
When an entity is dropped onto the designer, partial classes are made available in which you can extend
the validation logic. Figure 15-11 shows these partial class definitions within the Extensibility Method
Definitions region.
You can easily add validation logic by implementing these classes. For example, to implement the custom
Insert method, simply add the following code to the public partial class:
partial void InsertSalesOrderHeader(SalesOrderHeader instance)
{
this.
Pages:
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469