Constellation.Foundation.ModelMapping 9.1.11.16238

VERSION 9.1 is compiled for Sitecore 9.1 use and will not work on earlier versions.
Requires Sitecore 9.1
Requires .NET 4.7.1

Constellation is a collection of utilities for .NET CMS implementers.

The Foundation.ModelMapping library is inspired by AutoMapper and is designed to provide a quick, non-ORM method of mapping Sitecore Items to ViewModels. String properties on your ViewModel will be mapped to FieldRendered values from fields with the same names. Integer and DateTime property types can also be handled automatically, although you will not get page editor support for these types. There are a number of Attributes that you can assign to your ViewModel's properties to change the behavior of the Mapper.

Usage:
var modelMapper = (IModelMapper)ServiceLocator.ServiceProvider.GetService(typeof(IModelMapper)); // Dependency Injection of an IModelMapper is supported

TModel viewModel = modelMapper.MapItemToNew<TModel>(sourceItem);
Or: TModel viewmodel = item.MapToNew<TModel>();
Or: modelMapper.MapTo(item, model);

When using Item or ItemList extensions for mapping, the context IModelMapper is requested from the ServiceLocator, so any moc objects you use for testing are supported with these extension methods.

Constraints:
- Your ViewModel must have a public, parameterless constructor.
- Only Writable, Public Instance properties will be mapped.
- Within Sitecore, your field names can be human-legible. ModelMapper will attempt to convert the field name to a valid Property name. Simpler names work best.
You can use the Field's Display Name for better human legibility and keep the Field's actual name closer to a legit C# entity name.
- ViewModel properties can be:
- - Strings
- - HtmlStrings (recommended for RichText and FieldRenderer)
- - Integers
- - Decimals
- - DateTimes
- - Other ViewModels (recommended for DropLink, DropTree)
- - ICollection Generics of other ViewModels (recommended for Multilist, Treelist)
- - Random Plain Old Classes as long as they are Where T: class, new()

The following Model properties are mapped to Item properties rather than Item fields:
- ID - Maps to the Item.ID - Make sure you use Sitecore.Data.ID as the property type.
- Name - Maps to the Item.Name
- DisplayName - Maps to Item.DisplayName
- Url - Should be a string, not a Uri. Causes the current context LinkManager to generate a Url for the Item.
- Parent - Maps to the ViewModel you provide based on the Item.Parent.

Support for XML Field Attributes
- ImageField.Alt - use Model.FieldNameAlt
- ImageField.Height - use Model.FieldNameHeight
- GeneralLink.Target - use Model.FieldNameTarget
- etc.

Support for LinkField.TargetItem - use Model.FieldNameTargetItem and supply a class with public properties and a parameterless constructor.
Support for MultilistField.GetItems - use Model.FieldName and supply a generic ICollection<T> where "T" is new() and has properties you can map.

Extensible! See the Constellation.Foundation.ModelMapping.config file to change the way Fields are processed.

Install-Package Constellation.Foundation.ModelMapping -Version 9.1.11.16238
dotnet add package Constellation.Foundation.ModelMapping --version 9.1.11.16238
<PackageReference Include="Constellation.Foundation.ModelMapping" Version="9.1.11.16238" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Constellation.Foundation.ModelMapping --version 9.1.11.16238
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes

Fixed a bug in GeneralLink URL attribute mapper. It now correctly calls LinkField.GetFriendlyUrl for internal links.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
9.1.11.16238 98 2/28/2020
9.1.10.19264 159 12/20/2019
9.1.9.30419 80 12/19/2019
9.1.8.25631 80 12/9/2019
9.1.7.27091 69 12/6/2019
9.1.6.15984 221 6/4/2019
9.1.5.27908 147 6/3/2019
9.1.4.28433 170 5/28/2019
9.1.3.23444 184 4/11/2019
9.1.2.24353 200 3/6/2019
9.1.1.23876 217 1/18/2019
9.1.0.16301 252 12/7/2018
9.0.33.27934 226 10/25/2018
9.0.32.25356 197 10/20/2018
9.0.31.30043 183 10/19/2018
9.0.30.20651 193 10/18/2018
9.0.30.16759 202 10/18/2018
9.0.29.16036 196 10/18/2018
9.0.28.29823 208 10/17/2018
9.0.27.22655 192 10/16/2018
9.0.26.31767 184 10/14/2018
9.0.25.30713 180 10/14/2018
9.0.24.28294 207 10/14/2018
9.0.23.20463 290 7/23/2018
9.0.22.29260 287 7/3/2018
9.0.21.16778 326 5/31/2018
9.0.20.26586 289 5/25/2018
9.0.19.21403 335 5/18/2018
9.0.18.17384 362 2/20/2018
9.0.17.20638 330 2/12/2018
9.0.17.17874 337 2/12/2018
9.0.16.23947 304 1/12/2018
9.0.15.30124 325 1/11/2018
9.0.14.22754 317 1/11/2018
9.0.13.26948 272 1/10/2018
9.0.13.20538 329 1/10/2018
9.0.12.19321 328 1/10/2018
9.0.11.23261 340 1/8/2018
9.0.10.18305 354 12/8/2017
9.0.9.27813 390 12/6/2017
9.0.9.24928 319 12/6/2017
9.0.9.19108 313 12/6/2017
9.0.8.28378 283 12/5/2017
9.0.7.25385 274 12/5/2017
9.0.6.28191 266 12/4/2017
9.0.5.22638 288 12/3/2017
9.0.4.21382 288 12/3/2017
9.0.4.21146 273 12/3/2017
9.0.3.27874 310 12/1/2017
9.0.1.27414 268 11/30/2017
9.0.1.18427 280 11/30/2017
9.0.0.35644 306 11/29/2017
9.0.0.30418 284 11/29/2017
9.0.0.27220 271 11/29/2017
8.1.3.19984 29 5/18/2020
8.1.3.19261 32 5/18/2020