Class AttributeFilter
- 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.
The AttributeFilter DataSource is part of the Standard EAV Data Sources. It removes values from items so that the result is smaller, and doesn't publish confidential data. It's primarily used when providing data as JSON, so that not all values are published.
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. The following shows a demo which delivers both the data as-is, and also filtered to only deliver Name
and Country
:
This is what you get on the default-case (unfiltered):
"Default": [
{
"Name": "2sic",
"Country": "Switzerland",
"Notes": "<p>Secret notes</p>",
"Categories": [
{
"Id": 38646,
"Title": "Second"
}
],
"Id": 38653,
"Guid": "46a46d9e-f572-413c-a42e-a82ac40d929d",
"Title": "2sic",
"Modified": "2017-11-06T22:38:00.15Z"
},
...
]
This is what you get on the filtered stream:
"Cleaned": [
{
"Name": "2sic",
"Country": "Switzerland",
"Id": 38653,
"Guid": "46a46d9e-f572-413c-a42e-a82ac40d929d",
"Title": "2sic",
"Modified": "2017-11-06T22:38:00.15Z"
},
...
]
As you can see, the secret Notes
and the Categories
are not in the Cleaned stream any more.
There are three common use cases:
Programming With The Attribute Filter
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
Demo App and further links
You should find some examples in this demo App
History
- Introduced in EAV 3.x, 2sxc ca. v6
API Documentation
[PublicApi]
[VisualQuery(NiceName = "Remove Attribute/Property", UiHint = "Remove attributes/properties to limit what is available", Icon = "delete_sweep", Type = DataSourceType.Modify, NameId = "ToSic.Eav.DataSources.AttributeFilter, ToSic.Eav.DataSources", DynamicOut = false, In = new string[] { "Default*" }, ConfigurationType = "|Config ToSic.Eav.DataSources.AttributeFilter", HelpLink = "https://go.2sxc.org/DsAttributeFilter")]
public class AttributeFilter : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheKey, ICacheExpiring, ITimestamped, IHasLog, IDataSourceLinkable
- Inheritance
-
AttributeFilter
- Implements
- Inherited Members
Remarks
Had a major, breaking update in v15. Consult the guide to upgrade your custom data sources.
Properties
AttributeNames
A string containing one or more attribute names. like "FirstName" or "FirstName,LastName,Birthday"
[Configuration]
public string AttributeNames { get; set; }
Property Value
Mode
A string containing one or more attribute names. like "FirstName" or "FirstName,LastName,Birthday"
[Configuration(Fallback = "+")]
public string Mode { get; set; }