During the compilation process, the DataWindow control or DataStore object will be converted to PowerServer C# models and stored in the PowerServer C# solution > "AppModels" project > [appname] > "Models" folder.
Each model represents one DataWindow and contains the schema of tables, columns, and procedure/function parameters, as shown in the example below.
-
Each column in the DataWindow becomes a property in the C# class.
-
Data types are translated (e.g., string, int, DateTime).
Note
The original data type will be mapped to the C# data type, or the data type returned by PowerServer on executing SyntaxFromSQL. For the mapping rules, refer to Data type mappings.
-
The class might include metadata or attributes for database mapping (e.g., [Key], [Identity], [DwColumn], [ConcurrencyCheck], [PropertySave]).
namespace salesdemo_cloud { [DataWindow("d_dddw_address", DwStyle.Grid)] #region DwSelectAttribute [DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Person.Address\" ) @(_COLUMNS_PLACEHOLDER_) )")] #endregion public class D_Dddw_Address { [Identity] [SqlDefaultValue("autoincrement")] [DwColumn("Person.Address", "AddressID")] public int? Addressid { get; set; } [DwColumn("Person.Address", "AddressLine1")] public string Addressline1 { get; set; } [DwColumn("Person.Address", "City")] public string City { get; set; } [DwColumn("Person.Address", "StateProvinceID")] public int? Stateprovinceid { get; set; } } }
When the client sends requests for CRUD operations, PowerServer Web APIs uses the C# model to convert the incoming JSON data into a C# object, perform the database operation, and then convert the result back into JSON to return to the client.
The C# model serves as the foundation for:
-
Reading data from the database (e.g., mapping query results)
-
Writing data to the database (e.g., inserting, updating, deleting records)
-
Validating and structuring the JSON data exchanged between the client and server