Show / Hide Table of Contents

    IDataStore.GetModel<TModel>(int row, bool calcCompute) 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, bool calcCompute);
    

    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.

    calcCompute System.Boolean

    Whether to calculate columns with DwCompute attribute.

    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 and using the calcCompute parameter.

    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 Example2()
            {
                // 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 and using the calcCompute parameter.
                var person = datastore.GetModel<D_Person_With_Dwcompute>(0, true);
    
                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: Kim Abercrombie;
                */
            }
        }
    }
    

    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