Tuesday, July 11, 2017

a NavigationProperty at an .edmx

These kinda look like this if you look at the XML for the .edmx itself.

<NavigationProperty Name="BillingAddress"
      Relationship="MyModel.FK_Person_Address_Billing" FromRole="Person"
      ToRole="Address" />

 
 

Imagine if you will that we have a database table for Person and a database table for Address and that that the Person table has two nullable GUID columns for MailingId and BillingId that correspond to Address records. The above markup sort of manages the billing address relationship and allows one to dot dot dot out to an adjacent concept, if you will, with LINQ queries like so:

Place = new Locale()
{
   Name = p.BillingId == null ? null : p.BillingAddress.City
}

 
 

Clearly p above is the queried Person table but instead of the bridge pseudoobject being named Address or BillingId it's name can be kinda funny, in this case: BillingAddress

No comments:

Post a Comment