Business Logic & Scripting (C#)
This section is targeted at .NET and Pro-Code developers. It explains how to inject native, asynchronous C# logic into the Struktural Low-Code pipeline to enforce complex business rules, perform real-time UI calculations, and interact with external systems.
Please navigate through the following sub-sections:
4.1 Architecture & The Sandbox Details the Roslyn dynamic compilation process, AssemblyLoadContexts (ALC), and critical security restrictions (such as forbidden namespaces and the absolute ban on static members to prevent memory leaks).
4.2 Lifecycle Hooks A breakdown of the execution pipeline events. Explains when to use specific hooks like
OnValidate,BeforeCreate,OnChange, andOnQueryto intercept data mutation and frontend rendering.4.3 The Execution Context API reference for the
IScriptContextBridge. Details the injected variables available in every script, including the currentEntity, the EF CoreDbcontext, theUserprincipal, and theUicontroller.4.4 Database Persistence Rules Best practices for interacting with Entity Framework Core inside scripts. Explains when to use standard Change Tracking versus the
Db.SaveEntityAsync()helper to prevent context recycling collisions.4.5 System Services & Utilities Reference for injected services such as Email, Secrets Management, Secure Downloads, Archives, and FilterUtils.
4.6 EAV Metadata Manipulation Code examples demonstrating how to safely read and write dynamic properties within the Entity-Attribute-Value (EAV)
MetadataEntriescollection.*Note: The Exhaustive Scripting API Reference has been moved to 8.1 Scripting API Reference.*