DwChildAttribute Class
.NET Standard 2.x
Specifies the data source.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Inheritance Constructor
System.Attribute
Syntax
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class DwChildAttribute : Attribute
Constructors
Name | Description |
---|---|
DwChildAttribute(string dataColumn, string displayColumn, Type modelType) | Initializes a new instance of the DwChildAttribute class. |
Properties
Name | Return Type | Description |
---|---|---|
AutoRerieve | bool | Whether to automatically retrieve data. |
DataColumn | string | The data column. |
DisplayColumn | string | The display data column name. |
ModelType | Type | The model type for data source. |
Remarks
Corresponding to the DDDW of DataWindow.
AutoRerieve is optional. The default value is false. It can be set to true when the child model has no retrieval arguments.
Examples
The following code example demonstrates how to use the Model DwChild attribute, and use GetChild to get this child DataWindow.
Model: D_Course
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using SnapObjects.Data;
using DWNet.Data;
using Newtonsoft.Json;
namespace Appeon.ApiDoc.Models
{
[DataWindow("d_course", DwStyle.Grid)]
[Table("Course", Schema = "dbo")]
#region DwSelectAttribute
[DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Course\" ) @(_COLUMNS_PLACEHOLDER_) )")]
#endregion
[UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
[DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
public class D_Course
{
[Key]
[DwColumn("Course", "CourseID")]
public int Courseid { get; set; }
[ConcurrencyCheck]
[DwColumn("Course", "Title")]
public string Title { get; set; }
[ConcurrencyCheck]
[DwColumn("Course", "Credits")]
public int Credits { get; set; }
[ConcurrencyCheck]
[DwColumn("Course", "DepartmentID")]
[DwChild("Departmentid", "Name", typeof(Dddw_Department), AutoRetrieve = true)]
public int Departmentid { get; set; }
}
}
Example Method:
using System;
using DWNet.Data;
namespace Appeon.ApiDoc.DwChildAttributeExamples
{
public class DwChildAttributeExample
{
private readonly SchoolContext _context;
public DwChildAttributeExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
var datastore = new DataStore("d_course", _context);
datastore.Retrieve();
//Gets the child DataWindow.
var child = datastore.GetChild("Departmentid");
// Shows the total number of rows in the child DataWindow.
Console.WriteLine($"child RowCount={child.RowCount}.");
/* This code example produces the following output:
child RowCount=5.
*/
}
}
}
Example Refer To
DataWindow File: d_course