Show / Hide Table of Contents

    IDataStore<TModel>.GetChild<TChildModel>(Expression<Func<TModel, object>> columnSelector) 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

    IDataStore<TChildModel> GetChild<TChildModel>(Expression<Func<TModel, object>> columnSelector);
    

    Parameters

    columnSelector Func<TModel, TValue>

    A transform function to apply to each column.

    Returns

    IDataStore<TChildModel>

    The reference to the DataWindowChild.

    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 by Predicate object.

    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 Example3()
            {
                // 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.
                var department = datastore.GetChild<Dddw_Department>(a=> a.Departmentid);
    
                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:
                 
                DataWindowChild rowcount: 4
                Department ID: 2; Department Name: English
                */
            }
        }
    }
    

    Example Refer To

    Model Classes: D_Course Dddw_Department
    DataWindow File: d_course

    Back to top Generated by Appeon