Overview

Custom Select/Update/Insert/Delete

CRUD pipeline customization with custom queries and actions.

C# Hooks from the Host Project

From this version you can inject C# logic from the host project (e.g., WuicTest) at the following points:

  • beforeInsert, beforeUpdate, beforeDelete, beforeRestore
  • customizeInsert, customizeUpdate, customizeDelete, customizeRestore
  • customizeSelect, customizeCountSelect
  • customizeExcelField, customizeRowImport

The runtime hook context is available uniformly for all IUtilityHost methods via a static helper:

  • WEB_UI_CRAFTER.ProjectData.Servizi.Utility.GetCurrentCrudHookContext()

The framework automatically looks for a host class:

  • WEB_UI_CRAFTER.ProjectData.Servizi.UtilityHost
  • or WEB_UI_CRAFTER.ProjectData.Servizi.CustomCrudHooks

Alternatively you can configure an explicit class name with appsetting:

  • AppSettings.customCrudHookClass

Method Signatures (Host)

Minimum example:

Snippet 1C#
namespace WEB_UI_CRAFTER.ProjectData.Servizi
{
    public class UtilityHost
    {
        public void beforeInsert(string route, Dictionary<string, object> entity, string userId) { }

        public void customizeInsert(ref string query, string route, Dictionary<string, object> entity, string userId)

For customizeSelect/customizeCountSelect use the same framework signature (ref parameters included), so you can alter where, join, orderBy, customSelectClause, customCount.

Context Helper (Valid in All Hooks)

You can read the current context (route/action/screen/workflow + debug + executing method) in any hook method:

Snippet 2C#
using WEB_UI_CRAFTER.ProjectData.Servizi;

public void beforeUpdate(string route, Dictionary<string, object> entity, string userId)
{
    var ctx = Utility.GetCurrentCrudHookContext();
    // Examples:
    // ctx.route

The routeContext payload from the client is optional: if not present, the backend applies the unknown fallback without blocking the CRUD pipeline.

Operational Notes

  • If the host class/method does not exist, the framework maintains default behavior (no-op).
  • If the host method throws an exception, the CRUD call fails and the error surfaces to the client.