Datasets Tables (Reference) provide direct table-level database operations with automatic CRUD functionality and tag mapping. DatasetTable enables:
Tables simplify database interactions by eliminating manual SQL for common operations.
| Property | Description | Required |
|---|---|---|
| Name | Unique table identifier (no spaces) | Yes |
| DB | Database connection | Yes |
| TableName | Actual database table name | Yes |
| WhereCondition | Filter clause for operations | No |
| Access | Permission level (Read/Insert/ReadWrite/Unrestricted) | Yes |
| Mapping | Tag-to-column assignments | No |
| MappingDateTime | Time interpretation (UTC/Local) | No |
| Description | Documentation text | No |
| Level | Permissions | Use Case |
|---|---|---|
| Read | SELECT only | Viewing data |
| Insert | INSERT only | Adding records |
| ReadWrite | SELECT, INSERT, UPDATE, DELETE | Full CRUD |
| Unrestricted | All operations + ALTER | Development only |
Filter data using SQL WHERE syntax:
sql
Status = 1
Department = 'Production'
Timestamp > '2024-01-01'sql
BatchID = {Tag.Production/Batch_ID}
Temperature > {Tag.TankFarm/Tank1/Temp}
Operator = '{Tag.Current_Operator}'sql
Status IN (1, 2, 3)
AND Department = '{Tag.Department}'
AND Timestamp > {Tag.StartDate}| Column | Tag | Usage |
|---|---|---|
| ID | Tag.RecordID | Primary key |
| Name | Tag.ProductName | Display value |
| Count | Tag.Quantity | Numeric data |
| Status | Tag.Status | State tracking |
Tag mapping occurs in the original call domain:
Client-Initiated Calls:
Server-Initiated Calls:
| Requirement | Domain | Example |
|---|---|---|
| User-specific data | Client | Personal preferences |
| Shared data | Server | Production values |
| Session data | Client | Login information |
| Global state | Server | System status |
csharp
// Trigger select
@Dataset.Table.ProductionTable.Select = true;
// Get all results
DataTable data = @Dataset.Table.ProductionTable.SelectCommand();
// Check row count
int rows = @Dataset.Table.ProductionTable.RowCount;csharp
// Set values in mapped tags
@Tag.ProductName = "Widget-A";
@Tag.Quantity = 100;
@Tag.Status = 1;
// Execute insert
@Dataset.Table.ProductionTable.Insert = true;csharp
// Modify mapped tags
@Tag.Quantity = 150;
@Tag.Status = 2;
// Execute update (uses WhereCondition)
@Dataset.Table.ProductionTable.Update = true;csharp
// Set identifying values
@Tag.RecordID = 12345;
// Execute delete (uses WhereCondition)
@Dataset.Table.ProductionTable.Delete = true;csharp
public void BatchUpdate()
{
DataTable table = @Dataset.Table.MyTable.SelectCommand();
foreach(DataRow row in table.Rows)
{
row["Status"] = "Processed";
row["ProcessDate"] = DateTime.Now;
}
// Update all modified rows
@Dataset.Table.MyTable.UpdateCommand(table);
}csharp
// Change filter at runtime
@Dataset.Table.MyTable.WhereCondition =
string.Format("Date = '{0}'", DateTime.Today);
// Execute with new filter
@Dataset.Table.MyTable.Select = true;csharp
try
{
@Dataset.BeginTransaction();
@Dataset.Table.Table1.Insert = true;
@Dataset.Table.Table2.Update = true;
@Dataset.CommitTransaction();
}
catch
{
@Dataset.RollbackTransaction();
}Pattern 1: Direct Script Processing
csharp
DataTable result = @Dataset.Query.Query1.SelectCommand();
// Process data locally without server domain impact
foreach(DataRow row in result.Rows) {
// Local processing
}Pattern 2: Tag Distribution
csharp
// Assign to DataTable tag for module sharing
@Tag.MyDataTable = @Dataset.Query.Query1.SelectCommand();
// Now available to displays, reports, etc.Pattern 3: Mapped Navigation
csharp
// Configure mapping, then navigate rows
@Dataset.Query.Query1.Select();
@Dataset.Query.Query1.Next(); // Moves to next row| Setting | Behavior | Use Case |
|---|---|---|
| Local | Convert to local time | User displays |
| UTC | Keep as UTC | Server operations |
csharp
// Store as UTC, display as local
@Dataset.Table.EventLog.MappingDateTime = "UTC";
// Tag receives UTC, display converts
@Tag.EventTime = // Automatically convertedxml
<DataGrid DataSource="{Dataset.Table.ProductionTable}" />csharp
// Fill combo with table data
@Display.ComboBox.DataSource =
@Dataset.Table.LookupTable.SelectCommand();Control Data Volume:
Resource Planning:
Small Query: < 1,000 rows = Minimal impact
Medium Query: 1,000-10,000 rows = Monitor memory usage
Large Query: > 10,000 rows = Implement paginationsql
-- Use indexed columns
ID = {Tag.ID} -- Good if ID is indexed
-- Avoid functions on columns
YEAR(Date) = 2024 -- Bad
Date >= '2024-01-01' AND Date < '2025-01-01' -- Goodcsharp
// Instead of multiple single updates
for(int i = 0; i < 100; i++)
{
@Tag.ID = i;
@Dataset.Table.MyTable.Update = true; // Slow
}
// Use batch update
DataTable batch = PrepareData();
@Dataset.Table.MyTable.UpdateCommand(batch); // FastNo data returned:
Insert/Update fails:
Mapping not working:
Performance issues: