Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

For unidirectional relations no annotations at all are necessary for re motion to automate the mapping to the database in a meaningful way. re-motion simply takes a .NET declaration in the Person class like

Location Location { get; set; }

to mean "there is a unidirectional relationship between Person and Location", and there will be a foreign key in the Person table to its Location row in the Location table. Things are not as easy for bidirectional relationships, as we will see shortly.

If domain objects were not persisted in database tables we'd have difficulty finding all Person objects belonging to a given Location, because the .NET Location object can't be asked for it. Since domain objects are always persisted in a database, however, we can query the Person table for a given location and wrap up the query in a member function for the Location class. For bidirectional relations, re-motion generates such queries for keeping the .NET properties in sync with the database for you, and makes sure they work correctly at both ends of the relation. A unidirectional
relation, however, lacks this automation in the other direction, in this case the query for getting the persons belonging to a location.

  • No labels