This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -479,6 +479,41 @@ class CustomerAddress {
479
479
}
480
480
```
481
481
482
+ ### Self References
483
+
484
+ Self References are also supported for ** 1:1** relations where the Foreign Key can instead be on the parent table:
485
+
486
+ ``` csharp
487
+ public class Customer
488
+ {
489
+ ...
490
+ public int CustomerAddressId { get ; set ; }
491
+
492
+ [Reference ]
493
+ public CustomerAddress PrimaryAddress { get ; set ; }
494
+ }
495
+ ```
496
+
497
+ ### Foreign Key and References Attributes
498
+
499
+ References that don't follow the above naming conventions can be declared explicitly using
500
+ the ` [References] ` and ` [ForeignKey] ` attributes:
501
+
502
+ ``` csharp
503
+ public class Customer
504
+ {
505
+ [References (typeof (CustomerAddress ))]
506
+ public int PrimaryAddressId { get ; set ; }
507
+
508
+ [Reference ]
509
+ public CustomerAddress PrimaryAddress { get ; set ; }
510
+ }
511
+ ```
512
+
513
+ > Reference Attributes take precedence over naming conventions
514
+
515
+ ### Implicit Reference Conventions are applied by default
516
+
482
517
The implicit relationship above allows you to use any of these equilvalent APIs to JOIN tables:
483
518
484
519
``` csharp
You can’t perform that action at this time.
0 commit comments