Table of Contents

Class AttributeRename

Namespace
ToSic.Eav.DataSources
Assembly
ToSic.Eav.DataSources.dll

The base class for all DataSources, especially custom DataSources. It must always be inherited. It provides a lot of core functionality to get configurations, ensure caching and more.

Important: in most cases you will inherit the CustomDataSource DataSource for custom data sources.

TODO: update the standard list with attribute rename and the StreamSwitch one I made last week

The AttributeRename DataSource is part of the Standard EAV Data Sources. It renames attributes from items so that the result has more appropriate field/property names. Optionally it will also remove all fields which have not been renamed, in case you only want the smaller, renamed items.

How to use with the VisualQuery

When using the VisualQuery you can just drag it into your query. Now you can configure what properties you want and not.

In this screenshot you can see:

  1. The DataSource which we're configuring
  2. The field map renaming fields
  3. Toggle to keep attributes which were not renamed - default is True
  4. The optional type name which you can give the modified entities - default is blank, resulting in the original type being used

Programming With The AttributeRename DataSource

We recommend to use the VisualQuery where possible, as it's easier to understand and is identical for C# and JavaScript. It's also better because it separates data-retrieval from visualization.

Read also

You should find some examples in this demo App

History

  1. Introduced in EAV / 2sxc 10.27

API Documentation

[PublicApi]
[VisualQuery(NiceName = "Rename Attribute/Property", UiHint = "Rename some attributes / properties", Icon = "edit_attributes", Type = DataSourceType.Modify, NameId = "ToSic.Eav.DataSources.AttributeRename, ToSic.Eav.DataSources", DynamicOut = false, In = new string[] { "Default*" }, ConfigurationType = "c5918cb8-d35a-48c7-9380-a437edde66d2", HelpLink = "https://go.2sxc.org/DsAttributeRename")]
public class AttributeRename : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheKey, ICacheExpiring, ITimestamped, IHasLog, IDataSourceLinkable
Inheritance
AttributeRename
Implements
Inherited Members

Remarks

Had a major, breaking update in v15. Consult the guide to upgrade your custom data sources.

Properties

AttributeMap

A string containing one or more attribute maps. The syntax is "NewName=OldName" - one mapping per line

[Configuration]
public string AttributeMap { get; set; }

Property Value

string

KeepOtherAttributes

True/false if attributes not renamed should be preserved.

[Configuration(Fallback = true)]
public bool KeepOtherAttributes { get; set; }

Property Value

bool

TypeName

A string containing one or more attribute maps. The syntax is "NewName=OldName" - one mapping per line

[Configuration]
public string TypeName { get; set; }

Property Value

string