IDataStore<TModel>.GetChild<TChildModel>(string name, out IDataStore<TChildModel> child) Method
.NET Standard 2.x
Provides a reference to the DataWindowChild
, which you can use to manipulate that DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
bool GetChild<TChildModel>(string name, out IDataStore<TChildModel> child);
Parameters
name
System.String
A string which is the name of the column containing the DataWindowChild
.
child
IDataStore<TChildModel>
The reference to the DataWindowChild
.
Returns
System.Boolean
Returns true
if it succeeds.
Remarks
A DataWindowChild
object is a DropDownDataWindow within a DataWindow object
.
Use the GetChild
method when you need to explicitly retrieve data for a DataWindowChild
object. It automatically retrieves data for the child when retrieving the main DataStore, you need to explicitly retrieve data when there are retrieval arguments or when conditions change and you want to retrieve new rows.
Examples
The following code example demonstrates how to get the DataWindowChild
in the specified column.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStore_GenericExamples
{
public class GetChildExample
{
private readonly SchoolContext _context;
public GetChildExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example2()
{
// Instantiates a DataStore object with datawindow: d_course.
var datastore = new DataStore<D_Course>(_context);
datastore.Retrieve();
// The departmentid column has a DropDownDataWindow: dddw_deparment.
bool result = datastore.GetChild("departmentid", out IDataStore<Dddw_Department> department);
Console.WriteLine("Result:{0}", result);
Console.WriteLine("DataWindowChild rowcount: {0}",
department.RowCount);
Console.WriteLine(
"Department ID: {0}; Department Name: {1}",
department.GetItem<int>(1, "departmentid"),
department.GetItem<string>(1, "name"));
/*This code produces the following output:
Result: True
DataWindowChild rowcount: 4
Department ID: 2; Department Name: English
*/
}
}
}
Example Refer To
Model Classes: D_Course Dddw_Department
DataWindow File: d_course