Skip to content

Data Managers

What is a DataManager (DM)?

So far, we have created models that support basic CRUD operations. These operations are managed by the DataManager (DM) class, which contains the logic for all necessary actions in your application. Currently, only the default DatabaseDM for database access has been developed. However, you can integrate your own custom managers by implementing the GenericDM class.

At application startup, Aventus scans all classes marked as Storable and checks if a specific DataManager (DM) exists for each class. If no custom DM is found, Aventus will use a generic DM provided in the base configuration.

Data Managers (DMs) are intended to contain the core logic for your application. By convention, DMs are placed in the Logic.DM namespace, but you are free to organize your code as you see fit.

Creating a Custom Data Manager for an Object

To create a DM for an object, you simply need to define the following code:

UserDM.cs
using AventusSharp.Data.Manager.DB;
using Demo.Data;
namespace Demo.Logic.DM
{
public class UserDM : DatabaseDM<UserDM, User>
{
// Custom logic for UserDM can be added here
}
}

With this setup, Aventus will prioritize UserDM for managing the User class instead of using the default generic DM.

This approach allows you to define specific DMs tailored to each class, keeping the business logic organized and separate from other application layers.