Data Model Extension
Data model extension in APS v23 allows adding business-specific information while taking advantage of the core's robustness.
Extension Strategies
There are two main ways to extend the data model:
Adding Custom Fields (No-code/Low-code)
Through Process Studio, you can add fields to your forms. These fields are automatically persisted by APS in dynamic tables or additional columns. This is the recommended method for most business needs.
External Data Tables
For complex structures, you can create your own SQL tables in the APS database or in a third-party database, then expose them through APS:
- Creating SQL Views for reading.
- Using Web Queries to populate choice lists or grids.
Programmatic Access via SqlHelper
To interact with your data extensions in C#, use the core's SqlHelper class. It manages connections and transactions securely.
Executing a Simple Query
using Avanteam.Kernel;
using System.Data;
// Retrieving a DataSet
string sql = "SELECT * FROM MaTablePerso WHERE Statut = @statut";
DataSet ds = SqlHelper.ExecuteDataset(connString, CommandType.Text, sql, new SqlParameter("@statut", "Actif"));
Calling a Stored Procedure
int rowsAffected = SqlHelper.ExecuteNonQuery(connString, "sp_MaProcedureMetier", 123, "Donnée");
Custom ORM Mapping
If you develop .NET components, you can use Avanteam.Kernel.Reflection.ObjectMapping to map your SQL query results to your C# objects.
var myObj = new MaClasse();
ObjectMapping.FillObjectWithDataRow(myObj, dataReader);
SQL Server Recommendations
- Prefixing: Prefix your custom tables (e.g.,
CUS_,APP_) to avoid any conflicts with future APS updates. - Transactions: If you perform multiple related actions, use transactions via
SqlHelper.ExecuteNonQuery(transaction, ...). - Indexing: Don't forget to index columns frequently used in your search filters.