简体   繁体   中英

2sxc - Access other app's entities

In some contexts, entities are common to a group of apps. For example, I use a list of departments in my institution for at least 4 apps (different projects that cannot and should not be merged in a single app). Another example is the type of employes or even the list of employees.

Is it possible to create an entity accessible to every app in an easy and fast way?

I searched it, but can't find any documentation about this.

Is it related to the dotnet external use?

// the app id
var appId = 42;
// create a simple app object to then access datavar appSimple =
ToSic.SexyContent.Environment.Dnn7.Factory.App(appId);
// example getting all data of content type Tagvar tags =
appSimple.Data["Tag"];

If you are working with razor and just want to access the data in code, you can create an AppDataSource and tell it what App you need. Here's some Pseudo-code:

var otherApp = CreateSource<AppDataSource>();

otherApp.ZoneId = 74;
otherApp.AppId = 203;

// do this after setting the values
var categories = otherApp.Data["Categories"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM