SQL Query in ASP .NetCore project Page Events

Hi All,

and sorry for my English.

Just trying RadSystem from yesterday.

Created a new project .Net Core / Quasar

Before save a record, i would like to find a MAX value in a specific field and increment it of one unit.

I found Page Events section and then reach Pages → → Add → BeforeAdd event.

For sure i know that the SQL query is " SELECT MAX(cod) FROM customer" but how to run the query and obtain the value that i will increment afterward and before save?

I need to work like in Visual Studio or i have direct access to field and to the query with some routines “ready to use”?

I was unable to find information online.

Thanks in advance for your help.

Best regards.

Massimo

You have access to the variable. There are code snippets on the right side of the Page Event panel, double click on them and the code will be added, then you can edit it the way you want to. You can also write your C# code just like you do in visual studio.

Hi Willvin,

and thanks for your reply.

Can you please help me to find the official documentation where i can find all variable available in every event?

Thanks

Regards.

Massimo

Page Events | Documentation (radsystems.io)
The variable is passed to the page event function you see on the editor. And you event code should be written inside the function.

Example:

For ASP.net (C#)

private void beforeAdd(Employees postdata){
    //enter statement here
    postdata.field_name; // Access field
}

For Laravel (PHP)

private void beforeAdd($modeldata){
    //enter statement here
    $modeldata["field_name"]; // Access field
}

For NodeRad (Node.js)

async function beforeAdd(postdata, req){
    //enter statement here
    postdata.field_name; // Access field OR
    postdata["field_name"]; // Access field
}

Working on Page Events requires you have a basic knowledge on the language used on the project type you are working on.

To run a query to an existing table using the postdata.field_name as value for where, is there a way to use the existing database connection? As example, a ready to use function or macro? Or i need to access to the db from scratch?

I see this on CodeSnippets to fetch a record but where is explained/detailed this way of access a record?

Thanks.

Regards.

Massimo