This project is read-only.
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:

mapping.Relate(domain=>domain.NameAsAProperty,gui=>gui.NameAsAField);
As fields are considered a special case, by default fields will not be autorelated. To also autorelate fields, you must specify it explicitly:

var autoRelateFields = true;
mapping.AutoRelateEqualNames(false, autoRelateFields);
Note also that the relationsverification will not fail even if fields are not related:

mapping.GetRelationsVerification().AssertAllPropertiesRelated<GuiPerson>();
(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:

mapping.RelateTowardsRight(domain => domain.GetId(), gui => gui.Id);
but not towards methods:

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)

Last edited Sep 19, 2009 at 8:28 AM by ToreVestues, version 2

Comments

No comments yet.