Quantcast
Channel: glue Wiki & Documentation Rss Feed
Viewing all articles
Browse latest Browse all 20

Updated Wiki: Properties, Fields and Methods

$
0
0
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)

Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>