Suppressing Default Assignment Fields

In some situations you may not want a pair of similarly named fields to be matched. You can cause a pair of fields to be omitted from an assignment by listing one of the fields at one end of the relationship.

For the following two classes below, PersonInfo and AccountInfo, having an struct relationship, the same named fields are matched.

For this example we first create the objects for the PersonInfo and AccountInfo classes as described above:

AccountInfo account = new AccountInfo();
PersonInfo person = new PersonInfo();

This assignment:

account.assign(person);

is equivalent to the following three statements:

account.Id = person.Id;
account.Surname = person.Surname;
account.FirstName = person.FirstName;

By adding Id as a key to one end of the relationship, it is excluded from the generated assignment and now this assignment:

account.assign(person);

is equivalent to the following two statements; that is, the Id assignment will no longer be made:

account.Surname = person.Surname;
account.FirstName = person.FirstName;