Glue supports mapping between properties, methods and fields. But it is supported in different ways. Here the differences are explained.
Properties
Properties are the default, everything explained about Glue (unless stated otherwise) is valid for properties.
Fields
You can specify relations both away from and towards fields, like you specify a normal relation:
As fields are considered a special case, by default fields will not be autorelated. To also autorelate fields, you must specify it explicitly:
Note also that the relationsverification will not fail even if fields are not related:
(For complete example download the source, check out the Fields.cs in the GlueExamples-project)
Methods
A method can be used as a read only property in Glue. Which means you can have relations away from methods:
but not towards methods:
Note that with methods you can't autorelate, and you the relationsverification will not check for methods.
(For complete example download the source, check out the Methods.cs in the GlueExamples-project)
Properties
Properties are the default, everything explained about Glue (unless stated otherwise) is valid for properties.
Fields
You can specify relations both away from and towards fields, like you specify a normal relation:
mapping.Relate(domain=>domain.NameAsAProperty,gui=>gui.NameAsAField);
var autoRelateFields = true; mapping.AutoRelateEqualNames(false, autoRelateFields);
mapping.GetRelationsVerification().AssertAllPropertiesRelated<GuiPerson>();
Methods
A method can be used as a read only property in Glue. Which means you can have relations away from methods:
mapping.RelateTowardsRight(domain => domain.GetId(), gui => gui.Id);
mapping.RelateTowardsLeft(domain => domain.GetId(), gui => gui.Id)
Note that with methods you can't autorelate, and you the relationsverification will not check for methods.
(For complete example download the source, check out the Methods.cs in the GlueExamples-project)