Show / Hide Table of Contents

    IDataStore.GetModel<TModel>(int row) Method

    .NET Standard 2.x

    Obtains the TModel object of the specified row.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

     public TModel GetModel<TModel>(int row);
    

    Type Parameters

    TModel

    The type of a model class that matches with the current DataObject.

    Parameters

    row System.Int32

    The zero-based row number to get data.

    Returns

    TModel

    Returns the TModel object which contains the data of the row.

    Examples

    The following code example demonstrates how to get data according to the row number.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class GetModelExample
        {
            private readonly SchoolContext _context;
    
            public GetModelExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_person_with_dwcompute.
                var datastore = new DataStore("d_person_with_dwcompute", _context);
    
                // Retrieves data whose Personid = 1.
                datastore.RetrieveByKey(1);
    			
    			// Gets a clone of the first row.
                var person = datastore.GetModel<D_Person_With_Dwcompute>(0);
    
                Console.WriteLine("Personid: {0};Firstname: {1};Lastname: {2};Compute_Fullname:{3}",
                    person.Personid, person.Firstname, person.Lastname, person.Compute_Fullname);
    
                /*This code produces the following output:
                 
                Personid: 1; Firstname: Kim; Lastname: Abercrombie; Compute_Fullname: null;
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Person_With_Dwcompute
    DataWindow File: D_Person_With_Dwcompute

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon