Class AppData
The Data object on an App. It's also a data-source of type App,
so it has many streams, one for each content-type so you can use it in combination with other DataSources.
The special feature is that it also has methods for data-manipulation,
including Create, Update and Delete
Inheritance
Implements
Inherited Members
Namespace: ToSic.Eav.Apps
Assembly: ToSic.Eav.Apps.dll
Syntax
[PublicApi_Stable_ForUseInYourCode]
public sealed class AppData : App, IAppIdentitySync, IAppData, IDataSource, IDataSourceLinkable, ICacheInfo, ICacheKey, ICanPurgeListCache, IHasLog, IDataTarget, IMetadataSource, ICacheExpiring, ITimestamped, IAppIdentity, IZoneIdentity, IAppIdentityLight
Constructors
| Improve this Doc View SourceAppData(App.MyServices, LazySvc<SimpleDataController>)
Declaration
public AppData(App.MyServices services, LazySvc<SimpleDataController> dataController)
Parameters
Type | Name | Description |
---|---|---|
ToSic.Eav.DataSources.App.MyServices | services | |
LazySvc<ToSic.Eav.Api.Api01.SimpleDataController> | dataController |
Methods
| Improve this Doc View SourceCreate(String, Dictionary<String, Object>, String, ITarget)
Create a new entity in the storage.
Declaration
public IEntity Create(string contentTypeName, Dictionary<string, object> values, string userName = null, ITarget target = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeName | The type name |
System.Collections.Generic.Dictionary<System.String, System.Object> | values | a dictionary of values to be stored |
System.String | userName | the current user name - will be logged as the author |
ITarget | target | information if this new item is to be metadata for something |
Returns
Type | Description |
---|---|
IEntity |
Remarks
Changed in 2sxc 10.30 - now returns the id of the created items
Create(String, IEnumerable<Dictionary<String, Object>>, String)
Create a bunch of new entities in one single call (much faster, because cache doesn't need to repopulate in the mean time).
Declaration
public IEnumerable<IEntity> Create(string contentTypeName, IEnumerable<Dictionary<string, object>> multiValues, string userName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeName | The type name |
System.Collections.Generic.IEnumerable<System.Collections.Generic.Dictionary<System.String, System.Object>> | multiValues | many dictionaries, each will become an own item when stored |
System.String | userName | the current user name - will be logged as the author |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEntity> |
Remarks
You can't create items which are metadata with this, for that, please use the Create-one overload
Changed in 2sxc 10.30 - now returns the id of the created items
Delete(Int32, String)
Delete an existing item
Declaration
public void Delete(int entityId, string userName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | entityId | The item ID |
System.String | userName | the current user name - will be logged as the author of the change |
GetCustomMetadata<TKey>(TKey, String)
Declaration
public IEnumerable<IEntity> GetCustomMetadata<TKey>(TKey key, string contentTypeName = null)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
System.String | contentTypeName |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEntity> |
Type Parameters
Name | Description |
---|---|
TKey |
GetMetadata<TKey>(Int32, TKey, String)
Declaration
public IEnumerable<IEntity> GetMetadata<TKey>(int targetType, TKey key, string contentTypeName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | targetType | |
TKey | key | |
System.String | contentTypeName |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEntity> |
Type Parameters
Name | Description |
---|---|
TKey |
GetMetadata<TKey>(TargetTypes, TKey, String)
Declaration
public IEnumerable<IEntity> GetMetadata<TKey>(TargetTypes targetType, TKey key, string contentTypeName = null)
Parameters
Type | Name | Description |
---|---|---|
TargetTypes | targetType | |
TKey | key | |
System.String | contentTypeName |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEntity> |
Type Parameters
Name | Description |
---|---|
TKey |
Update(Int32, Dictionary<String, Object>, String)
Update an existing item.
Declaration
public void Update(int entityId, Dictionary<string, object> values, string userName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | entityId | The item ID |
System.Collections.Generic.Dictionary<System.String, System.Object> | values | a dictionary of values to be updated |
System.String | userName | the current user name - will be logged as the author of the change |