-
Notifications
You must be signed in to change notification settings - Fork 0
Foreign Keys
Aaron Aichlmayr edited this page Apr 11, 2019
·
1 revision
Foreign keys are represented by a number specifically annotated properties on both sides of the relationsip
Identify or create properties on both sides of the relationship which represent the fields used in the foreign key relationship. These will need to be annotated using SqlField annotations.
- Create a property on both sides of the relationship to represent the object linkage
- If on the one side of the relationship or it is One-To-One it should be
public ForeignObject propertyName { get; set; }
- If on the many side of the relationship it should be
public IEnumerable<ForeignObject> propertyName { get; set; }
- If on the one side of the relationship or it is One-To-One it should be
- Add a
[SqlGraphQLRelated(LocalProperty = "", ForeignProperty = "")]
annotation to both new properties. The LocalProperty and ForeignProperty values should contain the property names (not field names) identified in the first steps section.
Note: The two properties should contain the same values swapping Foreign and Local values
- Create a property on both sides of the relationship to represent the object linkage
public IEnumerable<ForeignObject> propertyName { get; set; }
- Add a
[SqlGraphQLRelated( LocalProperty = "", LocalJoinField = "", JoinTable = "", ForeignJoinField = "", ForeignProperty = "" )]
annotation to each property.- The LocalProperty and ForeignProperty values should contain the property names (not field names) identified in the first steps section.
- The JoinTable should contain the table used for the relationship
- The LocalJoinField should contain the database field in the JoinTable which matches the LocalProperty
- The ForeignJoinField should contain the database field in the JoinTable which matches the ForeignProperty
Note: The two properties should contain the same values swapping Foreign and Local values