Skip to content
This repository was archived by the owner on Feb 26, 2022. It is now read-only.

Latest commit

 

History

History
37 lines (29 loc) · 1.08 KB

File metadata and controls

37 lines (29 loc) · 1.08 KB
layout title category
datatype
Inheritance
uMapper

{% highlight c# %} // You can structure your model classes to reflect the inheritance // in the document type tree.

// Create your base map first. uMapper.CreateMap() // maps from "Artist" node type .ForProperty(x => x.Name, (node, paths) => "Hello", false);

// Create your derived maps later. // // The model SoloArtist inherits from Artist. // // This creates a map from the "SoloArtist" node type, // which inherits from the "Artist" node type. uMapper.CreateMap();

var soloArtist = uMapper.GetSingle(1061); // soloArtist.Name == "Hello"

// You can map a node to a base model. var artist = uMapper.Query().Single(1061);

// And cast it back: (artist as SoloArtist).Name // "Hello"

// Or get every node which maps to a base model: List allArtists = uMapper.Query(); // contains Artist and SoloArtist items

// Or get every node which is explicitly mapped to the base model: List baseArtists = uMapper.Query().Explicit(); // contains only Artist {% endhighlight %}