GitHub    Download    Forum
Overview
Tutorial
Database setup
Preparing the project
Establish the connection
Shut down the connection
DTDL types
Creating the schema
DADL classes
Entry point object
Write and read attributes
Write and read lists
Extending the schema
Modified entry point object
Write and read objects
Write and read object lists
C++ API
C# API
DTDL
DADL
Setup

Data Type Definition

To define our data types, we add a new file to the project. "Add > New item…" and select the "DTDL file" from the DataFS folder. We could name it whatever we want. This will be useful when we have several files but, for now, we just leave it as it is.
Remarks: You may have noticed the "DataFS Support" item template in the DataFS folder. This is automatically added whenever you add a new DTDL or DADL file. This option is only needed to prepare the project for DataFS if you want to add only existing files to your project.
We build our new "Supplies" class, which needs a unique GUID. You can let Visual Studio generate it for you using "Tools > Create GUID > 4. Registry Format".
In our "Supplies" class there, we want to have several attributes, namely a description of the object, when it was last updated and a list of shops to order our preferred items from.
class Supplies [id({5E494623-5D2F-4774-880D-8BA7DAE2D0CC})]
{
	wstring  Description;
	datetime LastUpdated;
	ShopList Shops;
};
Next, we define the "ShopList". Lists need a unique GUID, which you can also generate like before.
list ShopList [id({CB1192D6-2497-425D-B8F2-C831B00DD9FB})]
{
	wstring ShopName;
	wstring ShopURL;
};
We could define those classes in the global namespace. But namespaces can be used to improve separation of definitions. To demonstrate this, we will put everything into a namespace called "Tutorial". This is what the finished file looks like:
DataDefinition.dtdl
namespace Tutorial
{
	class Supplies [id({5E494623-5D2F-4774-880D-8BA7DAE2D0CC})]
	{
		wstring  Description;
		datetime LastUpdated;
		ShopList Shops;
	};

	list ShopList [id({CB1192D6-2497-425D-B8F2-C831B00DD9FB})]
	{
		wstring ShopName;
		wstring ShopURL;
	};
}
© 2022 Mobiland AG